Skip to content

Commit 9be7ea1

Browse files
committed
feat: Win/Linux Dual Compatible WORKSPACE
- Add support for OS compatibility in the `WORKSPACE` file and `BUILD` files across the repository - Upgrade bazel version to enable Windows builds in MSVC command prompt - Validate multiple builds on CI, including with new Bazel version
1 parent 533bacc commit 9be7ea1

File tree

37 files changed

+360
-59
lines changed

37 files changed

+360
-59
lines changed

.bazelversion

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.2.1
1+
6.3.2

WORKSPACE

+25
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,12 @@ new_local_repository(
4646
path = "/usr/local/cuda-12.1/",
4747
)
4848

49+
new_local_repository(
50+
name = "cuda_win",
51+
build_file = "@//third_party/cuda:BUILD",
52+
path = "C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.1/",
53+
)
54+
4955
#############################################################################################################
5056
# Tarballs and fetched dependencies (default - use in cases when building from precompiled bin and tarballs)
5157
#############################################################################################################
@@ -64,6 +70,13 @@ http_archive(
6470
urls = ["https://download.pytorch.org/libtorch/nightly/cu121/libtorch-shared-with-deps-latest.zip"],
6571
)
6672

73+
http_archive(
74+
name = "libtorch_win",
75+
build_file = "@//third_party/libtorch:BUILD",
76+
strip_prefix = "libtorch",
77+
urls = ["https://download.pytorch.org/libtorch/nightly/cu121/libtorch-win-shared-with-deps-latest.zip"],
78+
)
79+
6780
# Download these tarballs manually from the NVIDIA website
6881
# Either place them in the distdir directory in third_party and use the --distdir flag
6982
# or modify the urls to "file:///<PATH TO TARBALL>/<TARBALL NAME>.tar.gz
@@ -78,6 +91,18 @@ http_archive(
7891
],
7992
)
8093

94+
http_archive(
95+
name = "tensorrt_win",
96+
build_file = "@//third_party/tensorrt/archive:BUILD",
97+
sha256 = "d667bd10b178e239b621a8929008ef3e27967d181bf07a39845a0f99edeec47a",
98+
strip_prefix = "TensorRT-10.0.1.6",
99+
urls = [
100+
"https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/10.0.1/zip/TensorRT-10.0.1.6.Windows10.win10.cuda-12.4.zip",
101+
],
102+
)
103+
104+
105+
81106
####################################################################################
82107
# Locally installed dependencies (use in cases of custom dependencies or aarch64)
83108
####################################################################################

core/BUILD

+11-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,13 @@ config_setting(
1717
},
1818
)
1919

20+
config_setting(
21+
name = "windows",
22+
constraint_values = [
23+
"@platforms//os:windows",
24+
],
25+
)
26+
2027
cc_library(
2128
name = "core",
2229
srcs = [
@@ -31,8 +38,11 @@ cc_library(
3138
"//core/partitioning",
3239
"//core/runtime",
3340
"//core/util/logging",
34-
"@tensorrt//:nvinfer",
3541
] + select({
42+
":windows": ["@tensorrt_win//:nvinfer"],
43+
"//conditions:default": ["@tensorrt//:nvinfer"],
44+
}) + select({
45+
":windows": ["@libtorch_win//:libtorch"],
3646
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
3747
"//conditions:default": ["@libtorch"],
3848
}),

core/conversion/BUILD

+12-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "conversion",
1522
srcs = [
@@ -26,8 +33,11 @@ cc_library(
2633
"//core/conversion/var",
2734
"//core/ir",
2835
"//core/util:prelude",
29-
"@tensorrt//:nvinfer",
30-
] + select({
36+
] + select({
37+
":windows": ["@tensorrt_win//:nvinfer"],
38+
"//conditions:default": ["@tensorrt//:nvinfer"],
39+
}) + select({
40+
":windows": ["@libtorch_win//:libtorch"],
3141
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
3242
"//conditions:default": ["@libtorch"],
3343
}),

core/conversion/conversionctx/BUILD

+12-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "conversionctx",
1522
srcs = [
@@ -21,8 +28,11 @@ cc_library(
2128
deps = [
2229
"//core/ir",
2330
"//core/util:prelude",
24-
"@tensorrt//:nvinfer",
25-
] + select({
31+
] + select({
32+
":windows": ["@tensorrt_win//:nvinfer"],
33+
"//conditions:default": ["@tensorrt//:nvinfer"],
34+
}) + select({
35+
":windows": ["@libtorch_win//:libtorch"],
2636
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
2737
"//conditions:default": ["@libtorch"],
2838
}),

core/conversion/converters/BUILD

+19-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "weights",
1522
srcs = [
@@ -21,8 +28,11 @@ cc_library(
2128
deps = [
2229
"//core/conversion/conversionctx",
2330
"//core/util:prelude",
24-
"@tensorrt//:nvinfer",
2531
] + select({
32+
":windows": ["@tensorrt_win//:nvinfer"],
33+
"//conditions:default": ["@tensorrt//:nvinfer"],
34+
}) + select({
35+
":windows": ["@libtorch_win//:libtorch"],
2636
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
2737
"//conditions:default": ["@libtorch"],
2838
}),
@@ -41,8 +51,11 @@ cc_library(
4151
":weights",
4252
"//core/conversion/conversionctx",
4353
"//core/util:prelude",
44-
"@tensorrt//:nvinfer",
4554
] + select({
55+
":windows": ["@tensorrt_win//:nvinfer"],
56+
"//conditions:default": ["@tensorrt//:nvinfer"],
57+
}) + select({
58+
":windows": ["@libtorch_win//:libtorch"],
4659
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
4760
"//conditions:default": ["@libtorch"],
4861
}),
@@ -98,8 +111,11 @@ cc_library(
98111
"//core/conversion/var",
99112
"//core/plugins:torch_tensorrt_plugins",
100113
"//core/util:prelude",
101-
"@tensorrt//:nvinfer",
102114
] + select({
115+
":windows": ["@tensorrt_win//:nvinfer"],
116+
"//conditions:default": ["@tensorrt//:nvinfer"],
117+
}) + select({
118+
":windows": ["@libtorch_win//:libtorch"],
103119
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
104120
"//conditions:default": ["@libtorch"],
105121
}),

core/conversion/evaluators/BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "evaluators",
1522
srcs = [
@@ -28,6 +35,7 @@ cc_library(
2835
"//core/conversion/var",
2936
"//core/util:prelude",
3037
] + select({
38+
":windows": ["@libtorch_win//:libtorch"],
3139
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
3240
"//conditions:default": ["@libtorch"],
3341
}),

core/conversion/tensorcontainer/BUILD

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "tensorcontainer",
1522
srcs = [
@@ -20,8 +27,11 @@ cc_library(
2027
],
2128
deps = [
2229
"//core/util:prelude",
23-
"@tensorrt//:nvinfer",
2430
] + select({
31+
":windows": ["@tensorrt_win//:nvinfer"],
32+
"//conditions:default": ["@tensorrt//:nvinfer"],
33+
}) + select({
34+
":windows": ["@libtorch_win//:libtorch"],
2535
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
2636
"//conditions:default": ["@libtorch"],
2737
}),

core/conversion/var/BUILD

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "var",
1522
srcs = [
@@ -23,8 +30,11 @@ cc_library(
2330
"//core/conversion/converters:converter_util",
2431
"//core/conversion/tensorcontainer",
2532
"//core/util:prelude",
26-
"@tensorrt//:nvinfer",
2733
] + select({
34+
":windows": ["@tensorrt_win//:nvinfer"],
35+
"//conditions:default": ["@tensorrt//:nvinfer"],
36+
}) + select({
37+
":windows": ["@libtorch_win//:libtorch"],
2838
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
2939
"//conditions:default": ["@libtorch"],
3040
}),

core/ir/BUILD

+11-1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "ir",
1522
srcs = [
@@ -23,8 +30,11 @@ cc_library(
2330
],
2431
deps = [
2532
"//core/util:prelude",
26-
"@tensorrt//:nvinfer",
2733
] + select({
34+
":windows": ["@tensorrt_win//:nvinfer"],
35+
"//conditions:default": ["@tensorrt//:nvinfer"],
36+
}) + select({
37+
":windows": ["@libtorch_win//:libtorch"],
2838
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
2939
"//conditions:default": ["@libtorch"],
3040
}),

core/lowering/BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "lowering",
1522
srcs = [
@@ -26,6 +33,7 @@ cc_library(
2633
"//core/lowering/passes",
2734
"//core/util:prelude",
2835
] + select({
36+
":windows": ["@libtorch_win//:libtorch"],
2937
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
3038
"//conditions:default": ["@libtorch"],
3139
}),

core/lowering/passes/BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "passes",
1522
srcs = [
@@ -49,6 +56,7 @@ cc_library(
4956
deps = [
5057
"//core/util:prelude",
5158
] + select({
59+
":windows": ["@libtorch_win//:libtorch"],
5260
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
5361
"//conditions:default": ["@libtorch"],
5462
}),

core/partitioning/BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "partitioning",
1522
srcs = [
@@ -29,6 +36,7 @@ cc_library(
2936
"//core/partitioning/segmentedblock",
3037
"//core/util:prelude",
3138
] + select({
39+
":windows": ["@libtorch_win//:libtorch"],
3240
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
3341
"//conditions:default": ["@libtorch"],
3442
}),

core/partitioning/partitioningctx/BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "partitioningctx",
1522
srcs = [
@@ -25,6 +32,7 @@ cc_library(
2532
"//core/partitioning/segmentedblock",
2633
"//core/util:prelude",
2734
] + select({
35+
":windows": ["@libtorch_win//:libtorch"],
2836
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
2937
"//conditions:default": ["@libtorch"],
3038
}),

core/partitioning/partitioninginfo/BUILD

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,13 @@ config_setting(
1010
},
1111
)
1212

13+
config_setting(
14+
name = "windows",
15+
constraint_values = [
16+
"@platforms//os:windows",
17+
],
18+
)
19+
1320
cc_library(
1421
name = "partitioninginfo",
1522
srcs = [
@@ -24,6 +31,7 @@ cc_library(
2431
"//core/lowering",
2532
"//core/util:prelude",
2633
] + select({
34+
":windows": ["@libtorch_win//:libtorch"],
2735
":use_pre_cxx11_abi": ["@libtorch_pre_cxx11_abi//:libtorch"],
2836
"//conditions:default": ["@libtorch"],
2937
}),

0 commit comments

Comments
 (0)