Skip to content

Commit 2bf0785

Browse files
committed
bazel test //tensorrt/test:tensorrt_mlir_dialect_tests
1 parent 9f12bef commit 2bf0785

File tree

8 files changed

+82
-8
lines changed

8 files changed

+82
-8
lines changed

mlir-tensorrt/BUILD

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -691,6 +691,19 @@ cc_binary(
691691
],
692692
)
693693

694+
cc_binary(
695+
name = "tensorrt-opt",
696+
srcs = ["tensorrt/tensorrt-opt/tensorrt-opt.cpp"],
697+
copts = [
698+
"-DMLIR_TRT_TARGET_TENSORRT",
699+
],
700+
linkopts = ["-Wl,-rpath,/opt/src/mlir-tensorrt/bazel-mlir-tensorrt/external/tensorrt10_x86/targets/x86_64-linux-gnu/lib"],
701+
deps = [
702+
":TensorRTRegistration",
703+
"@llvm-project//mlir:MlirOptLib",
704+
],
705+
)
706+
694707
cc_binary(
695708
name = "mlir-tensorrt-opt",
696709
srcs = ["tools/MlirTensorRtOpt.cpp"],

mlir-tensorrt/WORKSPACE

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ rules_cuda_dependencies()
3030

3131
register_detected_cuda_toolchains()
3232

33-
3433
# -------------------------- #
3534
# Hermetic Python Setup #
3635
# -------------------------- #

mlir-tensorrt/tensorrt/tensorrt-opt/tensorrt-opt.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,21 @@
3333
#include "mlir/Tools/mlir-opt/MlirOptMain.h"
3434
#include "mlir/Transforms/Passes.h"
3535

36+
#ifdef MLIR_TRT_ENABLE_TESTING
3637
namespace mlir {
3738
void registerTestTensorKindAnalysisPass();
3839
}
40+
#endif // MLIR_TRT_ENABLE_TESTING
3941

4042
int main(int argc, char **argv) {
4143
mlir::DialectRegistry registry;
4244
registry.insert<mlir::tensorrt::TensorRTDialect, mlir::func::FuncDialect,
4345
mlir::tensor::TensorDialect, mlir::arith::ArithDialect,
4446
mlir::affine::AffineDialect, mlir::quant::QuantizationDialect,
4547
mlir::scf::SCFDialect>();
48+
#ifdef MLIR_TRT_ENABLE_TESTING
4649
mlir::registerTestTensorKindAnalysisPass();
50+
#endif // MLIR_TRT_ENABLE_TESTING
4751
mlir::func::registerInlinerExtension(registry);
4852
mlir::tensorrt::registerTensorRTTranslationCLOpts();
4953
mlir::tensorrt::registerTensorRTPasses();

mlir-tensorrt/tensorrt/test/BUILD

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Licensed under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
# Also available under a BSD-style license. See LICENSE.
5+
6+
load("@bazel_skylib//rules:expand_template.bzl", "expand_template")
7+
load("@llvm-project//llvm:lit_test.bzl", "lit_test")
8+
9+
expand_template(
10+
name = "lit_site_cfg_py",
11+
testonly = True,
12+
out = "lit.site.cfg.py",
13+
substitutions = {
14+
"@LIT_SITE_CFG_IN_HEADER@": "# Autogenerated, do not edit.",
15+
"\"@LLVM_TOOLS_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'llvm-project', 'llvm')",
16+
"\"@MLIR_TENSORRT_DIALECT_BINARY_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'tensorrt-mlir')",
17+
"\"@MLIR_TENSORRT_DIALECT_SOURCE_DIR@\"": "os.path.join(os.environ['TEST_SRCDIR'], 'tensorrt-mlir', 'tensorrt')",
18+
"@MLIR_ENABLE_BINDINGS_PYTHON@": "False",
19+
"@ENABLE_ASAN@": "False",
20+
},
21+
template = "lit.site.cfg.py.in",
22+
)
23+
24+
# Common data used by most lit tests.
25+
filegroup(
26+
name = "lit_data",
27+
testonly = True,
28+
data = [
29+
"lit.cfg.py",
30+
"lit.site.cfg.py",
31+
"@llvm-project//llvm:FileCheck",
32+
"@llvm-project//llvm:count",
33+
"@llvm-project//llvm:not",
34+
],
35+
)
36+
37+
[
38+
lit_test(
39+
name = "%s.test" % src,
40+
srcs = [src],
41+
data = [
42+
"//:tensorrt-opt",
43+
"//tensorrt/test:lit_data",
44+
],
45+
tags = ["tensorrt_mlir_dialect_tests"],
46+
)
47+
for src in glob(
48+
[
49+
"TensorRT/*.mlir",
50+
],
51+
exclude = [
52+
# exclude MLIR_TRT_ENABLE_TESTING related tests
53+
"TensorRT/tensor-kind-analysis.mlir",
54+
],
55+
)
56+
]
57+
58+
test_suite(
59+
name = "tensorrt_mlir_dialect_tests",
60+
tags = ["tensorrt_mlir_dialect_tests"],
61+
)

mlir-tensorrt/tensorrt/test/lit.cfg.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,7 @@
4040
# subdirectories contain auxiliary inputs for various tests in their parent
4141
# directories.
4242
config.excludes = ["Inputs", "Examples", "CMakeLists.txt", "README.txt", "LICENSE.txt"]
43-
config.tensorrt_dialect_tools_dir = os.path.join(
44-
config.tensorrt_dialect_obj_root, "bin"
45-
)
43+
config.tensorrt_dialect_tools_dir = os.path.join(config.tensorrt_dialect_obj_root)
4644
config.tensorrt_dialect_libs_dir = os.path.join(config.tensorrt_dialect_obj_root, "lib")
4745
config.substitutions.append(
4846
("%tensorrt_dialect_libs", config.tensorrt_dialect_libs_dir)

mlir-tensorrt/tensorrt/test/lit.site.cfg.py.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ import lit.llvm
1212
lit.llvm.initialize(lit_config, config)
1313

1414
# Let the main config do the real work.
15-
lit_config.load_config(config, "@MLIR_TENSORRT_DIALECT_SOURCE_DIR@/test/lit.cfg.py")
15+
lit_config.load_config(config, "@MLIR_TENSORRT_DIALECT_SOURCE_DIR@" + "/test/lit.cfg.py")

mlir-tensorrt/test/BUILD

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ filegroup(
3939
name = "lit_data",
4040
testonly = True,
4141
data = [
42+
"gpu_tools.py",
4243
"lit.cfg.py",
4344
"lit.site.cfg.py",
44-
"gpu_tools.py",
4545
"@llvm-project//llvm:FileCheck",
4646
"@llvm-project//llvm:count",
4747
"@llvm-project//llvm:not",
@@ -61,7 +61,6 @@ filegroup(
6161
requirement("nvidia-ml-py"),
6262
requirement("click"),
6363
requirement("numpy"),
64-
6564
],
6665
)
6766
for src in glob([

mlir-tensorrt/version.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
MLIR_TENSORRT_VERSION_MAJOR = "0"
44
MLIR_TENSORRT_VERSION_MINOR = "1"
55
MLIR_TENSORRT_VERSION_PATCH = "34"
6-
MLIR_TENSORRT_VERSION = "{}.{}.{}".format(MLIR_TENSORRT_VERSION_MAJOR, MLIR_TENSORRT_VERSION_MINOR, MLIR_TENSORRT_VERSION_PATCH)
6+
MLIR_TENSORRT_VERSION = "{}.{}.{}".format(MLIR_TENSORRT_VERSION_MAJOR, MLIR_TENSORRT_VERSION_MINOR, MLIR_TENSORRT_VERSION_PATCH)

0 commit comments

Comments
 (0)