• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# NVIDIA TensorRT
2# A high-performance deep learning inference optimizer and runtime.
3
4licenses(["notice"])
5
6load("@local_config_cuda//cuda:build_defs.bzl", "cuda_default_copts")
7load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
8
9package(default_visibility = ["//visibility:public"])
10
11exports_files(["LICENSE"])
12
13cc_library(
14    name = "tensorrt_headers",
15    hdrs = [
16        "tensorrt/include/tensorrt_config.h",
17        ":tensorrt_include",
18    ],
19    include_prefix = "third_party/tensorrt",
20    strip_include_prefix = "tensorrt/include",
21)
22
23cc_library(
24    name = "tensorrt",
25    srcs = [":tensorrt_lib"],
26    copts = cuda_default_copts(),
27    data = [":tensorrt_lib"],
28    linkstatic = 1,
29    deps = [
30        ":tensorrt_headers",
31        "@local_config_cuda//cuda",
32    ],
33)
34
35bzl_library(
36    name = "build_defs_bzl",
37    srcs = ["build_defs.bzl"],
38    deps = [
39        "@bazel_skylib//lib:selects",
40    ],
41)
42
43genrule(
44    name = "tensorrt_lib",
45    outs = [
46        "tensorrt/lib/libnvinfer.so.6",
47        "tensorrt/lib/libnvinfer_plugin.so.6",
48    ],
49    cmd = """cp -f "/usr/lib/x86_64-linux-gnu/libnvinfer.so.6" "$(location tensorrt/lib/libnvinfer.so.6)" && \
50cp -f "/usr/lib/x86_64-linux-gnu/libnvinfer_plugin.so.6" "$(location tensorrt/lib/libnvinfer_plugin.so.6)" """,
51)
52
53genrule(
54    name = "tensorrt_include",
55    outs = [
56        "tensorrt/include/NvInfer.h",
57        "tensorrt/include/NvUtils.h",
58        "tensorrt/include/NvInferPlugin.h",
59        "tensorrt/include/NvInferVersion.h",
60        "tensorrt/include/NvInferRuntime.h",
61        "tensorrt/include/NvInferRuntimeCommon.h",
62        "tensorrt/include/NvInferPluginUtils.h",
63    ],
64    cmd = """cp -f "/usr/include/x86_64-linux-gnu/NvInfer.h" "$(location tensorrt/include/NvInfer.h)" && \
65cp -f "/usr/include/x86_64-linux-gnu/NvUtils.h" "$(location tensorrt/include/NvUtils.h)" && \
66cp -f "/usr/include/x86_64-linux-gnu/NvInferPlugin.h" "$(location tensorrt/include/NvInferPlugin.h)" && \
67cp -f "/usr/include/x86_64-linux-gnu/NvInferVersion.h" "$(location tensorrt/include/NvInferVersion.h)" && \
68cp -f "/usr/include/x86_64-linux-gnu/NvInferRuntime.h" "$(location tensorrt/include/NvInferRuntime.h)" && \
69cp -f "/usr/include/x86_64-linux-gnu/NvInferRuntimeCommon.h" "$(location tensorrt/include/NvInferRuntimeCommon.h)" && \
70cp -f "/usr/include/x86_64-linux-gnu/NvInferPluginUtils.h" "$(location tensorrt/include/NvInferPluginUtils.h)" """,
71)
72