Skip to content

Commit

Permalink
chore: example on how to use external trtorch as a dep
Browse files Browse the repository at this point in the history
Signed-off-by: Naren Dasan <[email protected]>
Signed-off-by: Naren Dasan <[email protected]>
  • Loading branch information
narendasan committed Oct 12, 2021
1 parent 7ac6f1c commit 9860f85
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 87 deletions.
2 changes: 1 addition & 1 deletion BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ pkg_tar(
name = "libtrtorch",
srcs = [
"//:LICENSE",
"//bzl_def:BUILD.bzl",
"//bzl_def:BUILD",
"//bzl_def:WORKSPACE"
],
extension = "tar.gz",
Expand Down
81 changes: 77 additions & 4 deletions bzl_def/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,79 @@
package(default_visibility = ["//visibility:public"])

exports_files([
"WORKSPACE",
"BUILD.bzl"
])
config_setting(
name = "aarch64_linux",
constraint_values = [
"@platforms//cpu:aarch64",
"@platforms//os:linux",
],
)

config_setting(
name = "windows",
constraint_values = [
"@platforms//os:windows",
],
)

cc_library(
name = "libtrtorch",
srcs = select({
":windows": [
"lib/x64/trtorch.dll",
],
"//conditions:default": [
"lib/libtrtorch.so",
],
}),
hdrs = glob([
"include/**/*.h",
]),
strip_include_prefix = "include",
includes = ["include/"]
)

cc_library(
name = "libtrtorchrt",
srcs = select({
":windows": [
"lib/x64/trtorchrt.dll"
],
"//conditions:default": [
"lib/libtrtorchrt.so"
]
})
)

cc_library(
name = "libtrtorch_plugins",
srcs = select({
":windows": [
"lib/x64/trtorch_plugins.dll"
],
"//conditions:default": [
"lib/libtrtorch_plugins.so"
]
}),
hdrs = glob([
"include/trtorch/core/plugins/**/*.h",
]),
strip_include_prefix = "include",
includes = ["include/"]
)

cc_library(
name = "trtorch_core_hdrs",
hdrs = glob([
"include/trtorch/core/**/*.h"
]),
strip_include_prefix = "include/trtorch",
includes = ["include/trtorch/"]
)

# Alias for ease of use
cc_library(
name = "trtorch",
deps = [
":libtrtorch",
]
)
6 changes: 6 additions & 0 deletions bzl_def/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package(default_visibility = ["//visibility:public"])

exports_files([
"WORKSPACE",
"BUILD"
])
79 changes: 0 additions & 79 deletions bzl_def/BUILD.bzl

This file was deleted.

20 changes: 17 additions & 3 deletions tests/util/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ config_setting(
},
)

config_setting(
name = "ci_build_testing",
values = {
"define": "trtorch_src=pre_built"
}
)

cc_library(
name = "util",
srcs = [
Expand All @@ -20,9 +27,6 @@ cc_library(
"util.h",
],
deps = [
"//core/conversion",
"//core/util:prelude",
"//cpp:trtorch",
"@tensorrt//:nvinfer",
] + select({
":use_pre_cxx11_abi": [
Expand All @@ -33,5 +37,15 @@ cc_library(
"@libtorch//:libtorch",
"@libtorch//:caffe2",
],
}) + select({
":ci_build_testing": [
"@trtorch//:trtorch",
"@trtorch//:trtorch_core_hdrs"
],
"//conditions:default": [
"//cpp:trtorch",
"//core/conversion",
"//core/util:prelude"
]
}),
)

0 comments on commit 9860f85

Please sign in to comment.