Skip to content

Commit 83e0ed6

Browse files
committed
feat: Support non cxx11-abi builds for use in python api
Signed-off-by: Naren Dasan <[email protected]> Signed-off-by: Naren Dasan <[email protected]>
1 parent 2d677cd commit 83e0ed6

File tree

14 files changed

+143
-63
lines changed

14 files changed

+143
-63
lines changed

.bazelrc

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# limitations under the License.
1515
#
1616
# File: DL4AGX/.bazelrc
17-
# Description: Default bazel settings and toolchain configuration
17+
# Description: Default bazel settings and toolchain configuration
1818
##########################################################################
1919

2020
# +------------------------------------------------------------+
@@ -24,3 +24,8 @@
2424
build --cxxopt="-fdiagnostics-color=always"
2525
build --cxxopt='-std=c++14'
2626
#build --linkopt="-Wl,--no-as-needed"
27+
28+
29+
build:python --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
30+
build:python --linkopt="-D_GLIBCXX_USE_CXX11_ABI=0"
31+
build:python --define=api=python

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ tests/accuracy/datasets/data/*
2727
*.tgz
2828
docsrc/_build
2929
docsrc/_api
30-
docsrc/_tmp
30+
docsrc/_tmp
31+
*.so
32+
__pycache__
33+
*.egg-info

WORKSPACE

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
44
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")
55

66

7+
8+
79
http_archive(
810
name = "rules_python",
911
url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz",
@@ -32,6 +34,14 @@ new_local_repository(
3234
build_file = "@//third_party/cuda:BUILD",
3335
)
3436

37+
http_archive(
38+
name = "libtorch_non_cxx11_abi",
39+
build_file = "@//third_party/libtorch:BUILD",
40+
strip_prefix = "libtorch",
41+
sha256 = "ea8de17c5f70015583f3a7a43c7a5cdf91a1d4bd19a6a7bc11f074ef6cd69e27",
42+
urls = ["https://download.pytorch.org/libtorch/cu102/libtorch-shared-with-deps-1.5.0.zip"],
43+
)
44+
3545
http_archive(
3646
name = "libtorch",
3747
build_file = "@//third_party/libtorch:BUILD",
@@ -43,17 +53,15 @@ http_archive(
4353
# Downloaded distributions to use with --distdir
4454
http_archive(
4555
name = "cudnn",
46-
urls = ["https://developer.nvidia.com/compute/machine-learning/cudnn/secure/7.6.5.32/Production/10.2_20191118/cudnn-10.2-linux-x64-v7.6.5.32.tgz",],
47-
56+
urls = ["https://developer.nvidia.com/compute/machine-learning/cudnn/secure/7.6.5.32/Production/10.2_20191118/cudnn-10.2-linux-x64-v7.6.5.32.tgz"],
4857
build_file = "@//third_party/cudnn/archive:BUILD",
4958
sha256 = "600267f2caaed2fd58eb214ba669d8ea35f396a7d19b94822e6b36f9f7088c20",
5059
strip_prefix = "cuda"
5160
)
5261

5362
http_archive(
5463
name = "tensorrt",
55-
urls = ["https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.0/7.0.0.11/tars/TensorRT-7.0.0.11.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn7.6.tar.gz",],
56-
64+
urls = ["https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.0/7.0.0.11/tars/TensorRT-7.0.0.11.Ubuntu-18.04.x86_64-gnu.cuda-10.2.cudnn7.6.tar.gz"],
5765
build_file = "@//third_party/tensorrt/archive:BUILD",
5866
sha256 = "c7d73b2585b18aae68b740249efa8c8ba5ae852abe9a023720595432a8eb4efd",
5967
strip_prefix = "TensorRT-7.0.0.11"

core/BUILD

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

3+
config_setting(
4+
name = "dont_use_cxx11_abi",
5+
values = {
6+
"define": "api=python",
7+
}
8+
)
9+
310
cc_library(
411
name = "core",
512
hdrs = [
@@ -13,9 +20,11 @@ cc_library(
1320
"//core/execution",
1421
"//core/lowering",
1522
"//core/util/logging",
16-
"@libtorch//:libtorch",
1723
"@tensorrt//:nvinfer"
18-
],
24+
] + select({
25+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
26+
"//conditions:default": ["@libtorch//:libtorch"],
27+
}),
1928
alwayslink=True,
2029
)
2130

core/conversion/BUILD

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

3+
config_setting(
4+
name = "dont_use_cxx11_abi",
5+
values = {
6+
"define": "api=python",
7+
}
8+
)
9+
310
cc_library(
411
name = "conversion",
512
hdrs = [
@@ -13,12 +20,14 @@ cc_library(
1320
],
1421
deps = [
1522
"@tensorrt//:nvinfer",
16-
"@libtorch//:libtorch",
1723
"//core/conversion/conversionctx",
1824
"//core/conversion/converters",
1925
"//core/conversion/evaluators",
2026
"//core/util:prelude"
21-
]
27+
] + select({
28+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
29+
"//conditions:default": ["@libtorch//:libtorch"],
30+
})
2231
)
2332

2433
load("@rules_pkg//:pkg.bzl", "pkg_tar")

core/conversion/conversionctx/BUILD

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

3+
config_setting(
4+
name = "dont_use_cxx11_abi",
5+
values = {
6+
"define": "api=python",
7+
}
8+
)
9+
310
cc_library(
411
name = "conversionctx",
512
hdrs = [
@@ -10,9 +17,11 @@ cc_library(
1017
],
1118
deps = [
1219
"@tensorrt//:nvinfer",
13-
"@libtorch//:libtorch",
1420
"//core/util:prelude",
15-
]
21+
] + select({
22+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
23+
"//conditions:default": ["@libtorch//:libtorch"],
24+
})
1625
)
1726

1827
load("@rules_pkg//:pkg.bzl", "pkg_tar")

core/conversion/converters/BUILD

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

3+
config_setting(
4+
name = "dont_use_cxx11_abi",
5+
values = {
6+
"define": "api=python",
7+
}
8+
)
9+
310
cc_library(
411
name = "converters",
512
hdrs = [
@@ -24,11 +31,13 @@ cc_library(
2431
"impl/unary.cpp",
2532
],
2633
deps = [
27-
"@libtorch//:libtorch",
2834
"@tensorrt//:nvinfer",
2935
"//core/util:prelude",
30-
"//core/conversion/conversionctx"
31-
],
36+
"//core/conversion/conversionctx",
37+
] + select({
38+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
39+
"//conditions:default": ["@libtorch//:libtorch"],
40+
}),
3241
alwayslink = True,
3342
)
3443

core/conversion/evaluators/BUILD

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

3+
config_setting(
4+
name = "dont_use_cxx11_abi",
5+
values = {
6+
"define": "api=python",
7+
}
8+
)
9+
310
cc_library(
411
name = "evaluators",
512
hdrs = [
@@ -10,9 +17,11 @@ cc_library(
1017
"prim.cpp",
1118
],
1219
deps = [
13-
"@libtorch//:libtorch",
1420
"//core/util:prelude",
15-
],
21+
] + select({
22+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
23+
"//conditions:default": ["@libtorch//:libtorch"],
24+
}),
1625
alwayslink = True,
1726
)
1827

core/execution/BUILD

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

3+
config_setting(
4+
name = "dont_use_cxx11_abi",
5+
values = {
6+
"define": "api=python",
7+
}
8+
)
9+
310
cc_library(
411
name = "execution",
512
hdrs = [
@@ -12,9 +19,11 @@ cc_library(
1219
],
1320
deps = [
1421
"@tensorrt//:nvinfer",
15-
"@libtorch//:libtorch",
1622
"//core/util:prelude"
17-
],
23+
] + select({
24+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
25+
"//conditions:default": ["@libtorch//:libtorch"],
26+
}),
1827
alwayslink = True,
1928
)
2029

core/lowering/BUILD

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

3+
config_setting(
4+
name = "dont_use_cxx11_abi",
5+
values = {
6+
"define": "api=python",
7+
}
8+
)
9+
310
cc_library(
411
name = "lowering",
512
hdrs = [
@@ -11,10 +18,12 @@ cc_library(
1118
"register_const_op.cpp"
1219
],
1320
deps = [
14-
"@libtorch//:libtorch",
1521
"//core/lowering/passes",
1622
"//core/util:prelude"
17-
],
23+
] + select({
24+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
25+
"//conditions:default": ["@libtorch//:libtorch"],
26+
}),
1827
alwayslink = True
1928
)
2029

core/lowering/passes/BUILD

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

3+
config_setting(
4+
name = "dont_use_cxx11_abi",
5+
values = {
6+
"define": "api=python",
7+
}
8+
)
9+
310
cc_library(
411
name = "passes",
512
hdrs = [
@@ -16,8 +23,10 @@ cc_library(
1623
],
1724
deps = [
1825
"//core/util:prelude",
19-
"@libtorch//:libtorch",
20-
]
26+
] + select({
27+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
28+
"//conditions:default": ["@libtorch//:libtorch"],
29+
})
2130
)
2231

2332
load("@rules_pkg//:pkg.bzl", "pkg_tar")

core/util/BUILD

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package(default_visibility = ["//visibility:public"])
22

3+
config_setting(
4+
name = "dont_use_cxx11_abi",
5+
values = {
6+
"define": "api=python",
7+
}
8+
)
9+
310
cc_library(
411
name = "prelude",
512
hdrs = [
@@ -20,9 +27,10 @@ cc_library(
2027
hdrs = [
2128
"jit_util.h",
2229
],
23-
deps = [
24-
"@libtorch//:libtorch",
25-
]
30+
deps = select({
31+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
32+
"//conditions:default": ["@libtorch//:libtorch"],
33+
})
2634
)
2735

2836
cc_library(
@@ -51,9 +59,11 @@ cc_library(
5159
"build_info.h",
5260
],
5361
deps = [
54-
"@libtorch//:libtorch",
5562
"@tensorrt//:nvinfer"
56-
]
63+
] + select({
64+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
65+
"//conditions:default": ["@libtorch//:libtorch"],
66+
})
5767
)
5868

5969
cc_library(
@@ -65,11 +75,13 @@ cc_library(
6575
"trt_util.cpp"
6676
],
6777
deps = [
68-
"@libtorch//:libtorch",
6978
"@tensorrt//:nvinfer",
7079
"//core/util/logging",
7180
":macros"
72-
]
81+
] + select({
82+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
83+
"//conditions:default": ["@libtorch//:libtorch"],
84+
})
7385
)
7486

7587

@@ -79,7 +91,7 @@ pkg_tar(
7991
name = "include",
8092
package_dir = "core/util/",
8193
srcs = [
82-
"//core/util:build_info.h",
94+
"//core/util:build_info.h",
8395
"//core/util:macros.h",
8496
"//core/util:Exception.h",
8597
"//core/util:prelude.h",

core/util/logging/BUILD

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
package(default_visibility = ["//visibility:public"])
22

3+
config_setting(
4+
name = "dont_use_cxx11_abi",
5+
values = {
6+
"define": "api=python",
7+
}
8+
)
9+
310
cc_library(
411
name = "logging",
512
hdrs = [
@@ -10,7 +17,10 @@ cc_library(
1017
],
1118
deps = [
1219
"@tensorrt//:nvinfer"
13-
]
20+
] + select({
21+
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
22+
"//conditions:default": ["@libtorch//:libtorch"],
23+
})
1424
)
1525

1626
load("@rules_pkg//:pkg.bzl", "pkg_tar")

0 commit comments

Comments
 (0)