Skip to content

Commit

Permalink
feat: Support non cxx11-abi builds for use in python api
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 May 14, 2020
1 parent 2d677cd commit 83e0ed6
Show file tree
Hide file tree
Showing 14 changed files with 143 additions and 63 deletions.
7 changes: 6 additions & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#
# File: DL4AGX/.bazelrc
# Description: Default bazel settings and toolchain configuration
# Description: Default bazel settings and toolchain configuration
##########################################################################

# +------------------------------------------------------------+
Expand All @@ -24,3 +24,8 @@
build --cxxopt="-fdiagnostics-color=always"
build --cxxopt='-std=c++14'
#build --linkopt="-Wl,--no-as-needed"


build:python --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
build:python --linkopt="-D_GLIBCXX_USE_CXX11_ABI=0"
build:python --define=api=python
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,7 @@ tests/accuracy/datasets/data/*
*.tgz
docsrc/_build
docsrc/_api
docsrc/_tmp
docsrc/_tmp
*.so
__pycache__
*.egg-info
16 changes: 12 additions & 4 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")




http_archive(
name = "rules_python",
url = "https://github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz",
Expand Down Expand Up @@ -32,6 +34,14 @@ new_local_repository(
build_file = "@//third_party/cuda:BUILD",
)

http_archive(
name = "libtorch_non_cxx11_abi",
build_file = "@//third_party/libtorch:BUILD",
strip_prefix = "libtorch",
sha256 = "ea8de17c5f70015583f3a7a43c7a5cdf91a1d4bd19a6a7bc11f074ef6cd69e27",
urls = ["https://download.pytorch.org/libtorch/cu102/libtorch-shared-with-deps-1.5.0.zip"],
)

http_archive(
name = "libtorch",
build_file = "@//third_party/libtorch:BUILD",
Expand All @@ -43,17 +53,15 @@ http_archive(
# Downloaded distributions to use with --distdir
http_archive(
name = "cudnn",
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",],

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"],
build_file = "@//third_party/cudnn/archive:BUILD",
sha256 = "600267f2caaed2fd58eb214ba669d8ea35f396a7d19b94822e6b36f9f7088c20",
strip_prefix = "cuda"
)

http_archive(
name = "tensorrt",
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",],

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"],
build_file = "@//third_party/tensorrt/archive:BUILD",
sha256 = "c7d73b2585b18aae68b740249efa8c8ba5ae852abe9a023720595432a8eb4efd",
strip_prefix = "TensorRT-7.0.0.11"
Expand Down
13 changes: 11 additions & 2 deletions core/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "dont_use_cxx11_abi",
values = {
"define": "api=python",
}
)

cc_library(
name = "core",
hdrs = [
Expand All @@ -13,9 +20,11 @@ cc_library(
"//core/execution",
"//core/lowering",
"//core/util/logging",
"@libtorch//:libtorch",
"@tensorrt//:nvinfer"
],
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
}),
alwayslink=True,
)

Expand Down
13 changes: 11 additions & 2 deletions core/conversion/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "dont_use_cxx11_abi",
values = {
"define": "api=python",
}
)

cc_library(
name = "conversion",
hdrs = [
Expand All @@ -13,12 +20,14 @@ cc_library(
],
deps = [
"@tensorrt//:nvinfer",
"@libtorch//:libtorch",
"//core/conversion/conversionctx",
"//core/conversion/converters",
"//core/conversion/evaluators",
"//core/util:prelude"
]
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
})
)

load("@rules_pkg//:pkg.bzl", "pkg_tar")
Expand Down
13 changes: 11 additions & 2 deletions core/conversion/conversionctx/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "dont_use_cxx11_abi",
values = {
"define": "api=python",
}
)

cc_library(
name = "conversionctx",
hdrs = [
Expand All @@ -10,9 +17,11 @@ cc_library(
],
deps = [
"@tensorrt//:nvinfer",
"@libtorch//:libtorch",
"//core/util:prelude",
]
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
})
)

load("@rules_pkg//:pkg.bzl", "pkg_tar")
Expand Down
15 changes: 12 additions & 3 deletions core/conversion/converters/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "dont_use_cxx11_abi",
values = {
"define": "api=python",
}
)

cc_library(
name = "converters",
hdrs = [
Expand All @@ -24,11 +31,13 @@ cc_library(
"impl/unary.cpp",
],
deps = [
"@libtorch//:libtorch",
"@tensorrt//:nvinfer",
"//core/util:prelude",
"//core/conversion/conversionctx"
],
"//core/conversion/conversionctx",
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
}),
alwayslink = True,
)

Expand Down
13 changes: 11 additions & 2 deletions core/conversion/evaluators/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "dont_use_cxx11_abi",
values = {
"define": "api=python",
}
)

cc_library(
name = "evaluators",
hdrs = [
Expand All @@ -10,9 +17,11 @@ cc_library(
"prim.cpp",
],
deps = [
"@libtorch//:libtorch",
"//core/util:prelude",
],
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
}),
alwayslink = True,
)

Expand Down
13 changes: 11 additions & 2 deletions core/execution/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "dont_use_cxx11_abi",
values = {
"define": "api=python",
}
)

cc_library(
name = "execution",
hdrs = [
Expand All @@ -12,9 +19,11 @@ cc_library(
],
deps = [
"@tensorrt//:nvinfer",
"@libtorch//:libtorch",
"//core/util:prelude"
],
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
}),
alwayslink = True,
)

Expand Down
13 changes: 11 additions & 2 deletions core/lowering/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "dont_use_cxx11_abi",
values = {
"define": "api=python",
}
)

cc_library(
name = "lowering",
hdrs = [
Expand All @@ -11,10 +18,12 @@ cc_library(
"register_const_op.cpp"
],
deps = [
"@libtorch//:libtorch",
"//core/lowering/passes",
"//core/util:prelude"
],
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
}),
alwayslink = True
)

Expand Down
13 changes: 11 additions & 2 deletions core/lowering/passes/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "dont_use_cxx11_abi",
values = {
"define": "api=python",
}
)

cc_library(
name = "passes",
hdrs = [
Expand All @@ -16,8 +23,10 @@ cc_library(
],
deps = [
"//core/util:prelude",
"@libtorch//:libtorch",
]
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
})
)

load("@rules_pkg//:pkg.bzl", "pkg_tar")
Expand Down
28 changes: 20 additions & 8 deletions core/util/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "dont_use_cxx11_abi",
values = {
"define": "api=python",
}
)

cc_library(
name = "prelude",
hdrs = [
Expand All @@ -20,9 +27,10 @@ cc_library(
hdrs = [
"jit_util.h",
],
deps = [
"@libtorch//:libtorch",
]
deps = select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
})
)

cc_library(
Expand Down Expand Up @@ -51,9 +59,11 @@ cc_library(
"build_info.h",
],
deps = [
"@libtorch//:libtorch",
"@tensorrt//:nvinfer"
]
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
})
)

cc_library(
Expand All @@ -65,11 +75,13 @@ cc_library(
"trt_util.cpp"
],
deps = [
"@libtorch//:libtorch",
"@tensorrt//:nvinfer",
"//core/util/logging",
":macros"
]
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
})
)


Expand All @@ -79,7 +91,7 @@ pkg_tar(
name = "include",
package_dir = "core/util/",
srcs = [
"//core/util:build_info.h",
"//core/util:build_info.h",
"//core/util:macros.h",
"//core/util:Exception.h",
"//core/util:prelude.h",
Expand Down
12 changes: 11 additions & 1 deletion core/util/logging/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
package(default_visibility = ["//visibility:public"])

config_setting(
name = "dont_use_cxx11_abi",
values = {
"define": "api=python",
}
)

cc_library(
name = "logging",
hdrs = [
Expand All @@ -10,7 +17,10 @@ cc_library(
],
deps = [
"@tensorrt//:nvinfer"
]
] + select({
":dont_use_cxx11_abi": ["@libtorch_non_cxx11_abi//:libtorch"],
"//conditions:default": ["@libtorch//:libtorch"],
})
)

load("@rules_pkg//:pkg.bzl", "pkg_tar")
Expand Down
Loading

0 comments on commit 83e0ed6

Please sign in to comment.