Repository navigation
Expand file tree
/
Copy pathtensorrt_configure.bzl
More file actions
57 lines (48 loc) · 1.46 KB
/
Copy pathtensorrt_configure.bzl
File metadata and controls
57 lines (48 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
"""Build rule generator for locally installed TensorRT."""
# TensorFlow already exposes TensorRT, but not the parsers that are part of it.
# This rule therefore exposes just the parsers.
def _get_env_var(repository_ctx, name, default):
if name in repository_ctx.os.environ:
return repository_ctx.os.environ[name]
return default
def _impl(repository_ctx):
tensorrt_lib_path = _get_env_var(
repository_ctx,
"TENSORRT_INSTALL_PATH",
"/usr/lib/x86_64-linux-gnu",
)
tensorrt_include_path = _get_env_var(
repository_ctx,
"TENSORRT_INCLUDE_PATH",
tensorrt_lib_path.replace("lib", "include"),
)
repository_ctx.symlink(tensorrt_include_path, "tensorrt/include")
repository_ctx.symlink(tensorrt_lib_path, "tensorrt/lib")
repository_ctx.file("BUILD", """
package(default_visibility = ["//visibility:public"])
cc_library(
name = "nv_infer",
srcs = glob([
"tensorrt/lib/libnvinfer.so*",
]),
)
cc_library(
name = "tensorrt_headers",
hdrs = glob(["tensorrt/include/Nv*.h"]),
)
cc_library(
name = "nvparsers",
srcs = glob([
"tensorrt/include/Nv*.h",
"tensorrt/lib/libnvparsers.so*",
]),
hdrs = [
"tensorrt/include/NvOnnxParser.h",
"tensorrt/include/NvUffParser.h",
],
)
""")
tensorrt_configure = repository_rule(
implementation = _impl,
environ = ["TENSORRT_INSTALL_PATH", "TENSORRT_INCLUDE_PATH"],
)