Skip to content

Commit 9860f85

Browse files
committed
chore: example on how to use external trtorch as a dep
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent 7ac6f1c commit 9860f85

File tree

5 files changed

+101
-87
lines changed

5 files changed

+101
-87
lines changed

BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pkg_tar(
6565
name = "libtrtorch",
6666
srcs = [
6767
"//:LICENSE",
68-
"//bzl_def:BUILD.bzl",
68+
"//bzl_def:BUILD",
6969
"//bzl_def:WORKSPACE"
7070
],
7171
extension = "tar.gz",

bzl_def/BUILD

Lines changed: 77 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,79 @@
11
package(default_visibility = ["//visibility:public"])
22

3-
exports_files([
4-
"WORKSPACE",
5-
"BUILD.bzl"
6-
])
3+
config_setting(
4+
name = "aarch64_linux",
5+
constraint_values = [
6+
"@platforms//cpu:aarch64",
7+
"@platforms//os:linux",
8+
],
9+
)
10+
11+
config_setting(
12+
name = "windows",
13+
constraint_values = [
14+
"@platforms//os:windows",
15+
],
16+
)
17+
18+
cc_library(
19+
name = "libtrtorch",
20+
srcs = select({
21+
":windows": [
22+
"lib/x64/trtorch.dll",
23+
],
24+
"//conditions:default": [
25+
"lib/libtrtorch.so",
26+
],
27+
}),
28+
hdrs = glob([
29+
"include/**/*.h",
30+
]),
31+
strip_include_prefix = "include",
32+
includes = ["include/"]
33+
)
34+
35+
cc_library(
36+
name = "libtrtorchrt",
37+
srcs = select({
38+
":windows": [
39+
"lib/x64/trtorchrt.dll"
40+
],
41+
"//conditions:default": [
42+
"lib/libtrtorchrt.so"
43+
]
44+
})
45+
)
46+
47+
cc_library(
48+
name = "libtrtorch_plugins",
49+
srcs = select({
50+
":windows": [
51+
"lib/x64/trtorch_plugins.dll"
52+
],
53+
"//conditions:default": [
54+
"lib/libtrtorch_plugins.so"
55+
]
56+
}),
57+
hdrs = glob([
58+
"include/trtorch/core/plugins/**/*.h",
59+
]),
60+
strip_include_prefix = "include",
61+
includes = ["include/"]
62+
)
63+
64+
cc_library(
65+
name = "trtorch_core_hdrs",
66+
hdrs = glob([
67+
"include/trtorch/core/**/*.h"
68+
]),
69+
strip_include_prefix = "include/trtorch",
70+
includes = ["include/trtorch/"]
71+
)
72+
73+
# Alias for ease of use
74+
cc_library(
75+
name = "trtorch",
76+
deps = [
77+
":libtrtorch",
78+
]
79+
)

bzl_def/BUILD.bazel

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
exports_files([
4+
"WORKSPACE",
5+
"BUILD"
6+
])

bzl_def/BUILD.bzl

Lines changed: 0 additions & 79 deletions
This file was deleted.

tests/util/BUILD

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ config_setting(
77
},
88
)
99

10+
config_setting(
11+
name = "ci_build_testing",
12+
values = {
13+
"define": "trtorch_src=pre_built"
14+
}
15+
)
16+
1017
cc_library(
1118
name = "util",
1219
srcs = [
@@ -20,9 +27,6 @@ cc_library(
2027
"util.h",
2128
],
2229
deps = [
23-
"//core/conversion",
24-
"//core/util:prelude",
25-
"//cpp:trtorch",
2630
"@tensorrt//:nvinfer",
2731
] + select({
2832
":use_pre_cxx11_abi": [
@@ -33,5 +37,15 @@ cc_library(
3337
"@libtorch//:libtorch",
3438
"@libtorch//:caffe2",
3539
],
40+
}) + select({
41+
":ci_build_testing": [
42+
"@trtorch//:trtorch",
43+
"@trtorch//:trtorch_core_hdrs"
44+
],
45+
"//conditions:default": [
46+
"//cpp:trtorch",
47+
"//core/conversion",
48+
"//core/util:prelude"
49+
]
3650
}),
3751
)

0 commit comments

Comments
 (0)