Skip to content

Commit 887325d

Browse files
authored
Merge pull request #389 from NVIDIA/1.8_update
feat!: Updating versions of CUDA, cuDNN, TensorRT and PyTorch
2 parents c0b9ec0 + e0b70be commit 887325d

34 files changed

+183
-127
lines changed

.github/workflows/docgen.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
- name: Run image
2323
run: docker run -it -d --name builder -v $GITHUB_WORKSPACE:/workspace -w /workspace docker.pkg.github.com/nvidia/trtorch/docgen:latest
2424
- name: Build python package
25-
run: docker exec builder bash -c "cp docker/WORKSPACE.docker WORKSPACE && cd py && python3 setup.py install"
25+
run: docker exec builder bash -c "cp docker/WORKSPACE.docs WORKSPACE && cd py && python3 setup.py install"
2626
- name: Generate new docs
2727
run: docker exec builder bash -c "cd docsrc && make html"
2828
- uses: stefanzweifel/git-auto-commit-action@v4

.github/workflows/linter.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
- name: Run image
2020
run: |
2121
docker run -it -d --name cpplinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace docker.pkg.github.com/nvidia/trtorch/docgen:latest
22-
docker exec cpplinter bash -c "cp /workspace/docker/WORKSPACE.docker /workspace/WORKSPACE"
22+
docker exec cpplinter bash -c "cp /workspace/docker/WORKSPACE.docs /workspace/WORKSPACE"
2323
env:
2424
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
2525
- name: Install dependencies
@@ -41,7 +41,7 @@ jobs:
4141
- name: Run image
4242
run: |
4343
docker run -it -d --name pylinter -e GITHUB_TOKEN=$GITHUB_TOKEN -v $GITHUB_WORKSPACE:/workspace -v $GITHUB_EVENT_PATH:/GITHUB_EVENT.json -w /workspace docker.pkg.github.com/nvidia/trtorch/docgen:latest
44-
docker exec pylinter bash -c "cp /workspace/docker/WORKSPACE.docker /workspace/WORKSPACE"
44+
docker exec pylinter bash -c "cp /workspace/docker/WORKSPACE.docs /workspace/WORKSPACE"
4545
env:
4646
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
4747
- name: Install dependencies

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ We use the PyTorch Slack for communication about core development, integration w
1616

1717
- Use the built in linting tools to ensure that your code matches the style guidelines
1818
```sh
19-
# C++ Linting (After installing clang-format)
19+
# C++ Linting (After installing clang-format [Version 9.0.0])
2020
# Print non-conforming sections of code
2121
bazel run //tools/linter:cpplint_diff -- //...
2222
# Modify code to conform with style guidelines

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ torch.jit.save(trt_ts_module, "trt_torchscript_module.ts")
7373
### Dependencies
7474
These are the following dependencies used to verify the testcases. TRTorch can work with other versions, but the tests are not guaranteed to pass.
7575

76-
- Bazel 3.7.0
77-
- Libtorch 1.7.x (built with CUDA 11.0)
78-
- CUDA 11.0 (10.2 on Jetson)
79-
- cuDNN 8
80-
- TensorRT 7.2
76+
- Bazel 4.0.0
77+
- Libtorch 1.8.0 (built with CUDA 11.1)
78+
- CUDA 11.1 (10.2 on Jetson)
79+
- cuDNN 8.1
80+
- TensorRT 7.2.3
8181

8282
## Prebuilt Binaries and Wheel files
8383

WORKSPACE

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ git_repository(
3535
# CUDA should be installed on the system locally
3636
new_local_repository(
3737
name = "cuda",
38-
path = "/usr/local/cuda-11.0/",
38+
path = "/usr/local/cuda-11.1/",
3939
build_file = "@//third_party/cuda:BUILD",
4040
)
4141

@@ -53,16 +53,16 @@ http_archive(
5353
name = "libtorch",
5454
build_file = "@//third_party/libtorch:BUILD",
5555
strip_prefix = "libtorch",
56-
sha256 = "117f6dd65b7267839197397edd0b10fd2900b0f291e3e54b0b800caefc31bcb6",
57-
urls = ["https://download.pytorch.org/libtorch/cu110/libtorch-cxx11-abi-shared-with-deps-1.7.1%2Bcu110.zip"],
56+
sha256 = "62a2c06761c32576b30f5884240cf675b937945d929e4b13cc776de8d9c2236c",
57+
urls = ["https://download.pytorch.org/libtorch/cu111/libtorch-cxx11-abi-shared-with-deps-1.8.0%2Bcu111.zip"],
5858
)
5959

6060
http_archive(
6161
name = "libtorch_pre_cxx11_abi",
6262
build_file = "@//third_party/libtorch:BUILD",
6363
strip_prefix = "libtorch",
64-
sha256 = "c77f926afd55d7e860ec9c7abc992c25be77c89771c3ec6fcc13ea42f07d46df",
65-
urls = ["https://download.pytorch.org/libtorch/cu110/libtorch-shared-with-deps-1.7.1%2Bcu110.zip"],
64+
sha256 = "1c8b0c0883dd17f5ce952d42ec5f7f0cc7ceb370307535cee26a66c10419f1f6",
65+
urls = ["https://download.pytorch.org/libtorch/cu111/libtorch-shared-with-deps-1.8.0%2Bcu111.zip"],
6666
)
6767

6868
# Download these tarballs manually from the NVIDIA website
@@ -71,18 +71,18 @@ http_archive(
7171

7272
http_archive(
7373
name = "cudnn",
74-
urls = ["https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.0.5/11.0_20201106/cudnn-11.0-linux-x64-v8.0.5.39.tgz",],
74+
urls = ["https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.1.1.33/11.2_20210301/cudnn-11.2-linux-x64-v8.1.1.33.tgz",],
7575
build_file = "@//third_party/cudnn/archive:BUILD",
76-
sha256 = "4e16ee7895deb4a8b1c194b812ba49586ef7d26902051401d3717511898a9b73",
76+
sha256 = "98a8784e92862f20018d20c281b30d4a0cd951f93694f6433ccf4ae9c502ba6a",
7777
strip_prefix = "cuda"
7878
)
7979

8080
http_archive(
8181
name = "tensorrt",
82-
urls = ["https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.2.2/tars/TensorRT-7.2.2.3.Ubuntu-18.04.x86_64-gnu.cuda-11.0.cudnn8.0.tar.gz",],
82+
urls = ["https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/7.2.3/tars/TensorRT-7.2.3.4.Ubuntu-18.04.x86_64-gnu.cuda-11.1.cudnn8.1.tar.gz",],
8383
build_file = "@//third_party/tensorrt/archive:BUILD",
84-
strip_prefix = "TensorRT-7.2.2.3",
85-
sha256 = "b5c325e38e1d92ce1ce92ca8b54ede9c224bf128c9a53eb0b9022f1ee4313ee0"
84+
strip_prefix = "TensorRT-7.2.3.4",
85+
sha256 = "d3a1f478e304b48878604fac70ce7920fece71f9cac62f925c9c59c197f5d087"
8686
)
8787

8888
####################################################################################

core/conversion/converters/impl/plugins/interpolate_plugin.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,8 @@ int InterpolatePlugin::enqueue(
254254
cudaStream_t stream) {
255255
#if NV_TENSORRT_MAJOR < 7 || (NV_TENSORRT_MAJOR == 7 && NV_TENSORRT_MINOR < 1)
256256
at::Tensor input = at::from_blob((void*)inputs[0], util::toVec(inputDesc->dims), [](void*) {}, tensor_options_);
257-
at::Tensor output = at::from_blob(outputs[0], util::volume(outputDesc->dims), [](void*) {}, tensor_options_);
257+
at::Tensor output = at::from_blob(
258+
outputs[0], util::volume(outputDesc->dims), [](void*) {}, tensor_options_);
258259

259260
at::cuda::CUDAStream torch_stream = at::cuda::getStreamFromPool();
260261
at::cuda::CUDAStreamGuard torch_guard(torch_stream);

core/conversion/evaluators/aten.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,20 @@ auto aten_registrations TRTORCH_UNUSED =
396396
EvalOptions().validSchemas({
397397
"aten::numel(Tensor self) -> int",
398398
})})
399+
.evaluator({c10::Symbol::fromQualString("aten::t"),
400+
[](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
401+
auto tensor_var = args.at(n->input(0));
402+
if (tensor_var.IValue()->isTensor()) {
403+
auto tensor = tensor_var.unwrapToTensor();
404+
return tensor.t();
405+
} else {
406+
TRTORCH_THROW_ERROR("Unimplemented data type for aten::t evaluator: ITensor");
407+
return {};
408+
}
409+
},
410+
EvalOptions().validSchemas({
411+
"aten::t(Tensor self) -> Tensor",
412+
})})
399413
.evaluator({c10::Symbol::fromQualString("aten::dim"),
400414
[](const torch::jit::Node* n, kwargs& args) -> c10::optional<torch::jit::IValue> {
401415
auto tensor_var = args.at(n->input(0));

core/lowering/lowering.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void LowerGraph(std::shared_ptr<torch::jit::Graph>& g) {
3636
torch::jit::LowerAllTuples(g);
3737
passes::RemoveContiguous(g);
3838
passes::RemoveDropout(g);
39-
passes::FuseFlattenLinear(g);
39+
passes::LinearToAddMM(g);
4040
passes::Conv2DToConvolution(g);
4141
passes::Conv3DToConvolution(g);
4242
passes::FuseAddMMBranches(g);

core/lowering/passes/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ cc_library(
1717
"conv3d_to_convolution.cpp",
1818
"exception_elimination.cpp",
1919
"fuse_addmm_branches.cpp",
20-
"fuse_flatten_linear.cpp",
20+
"linear_to_addmm.cpp",
2121
"remove_bn_dim_check.cpp",
2222
"remove_contiguous.cpp",
2323
"remove_dropout.cpp",

core/lowering/passes/fuse_flatten_linear.cpp renamed to core/lowering/passes/linear_to_addmm.cpp

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,31 @@ namespace core {
77
namespace lowering {
88
namespace passes {
99

10-
void FuseFlattenLinear(std::shared_ptr<torch::jit::Graph>& graph) {
10+
void LinearToAddMM(std::shared_ptr<torch::jit::Graph>& graph) {
1111
// TensorRT implicitly adds a flatten layer infront of FC layers if necessary
1212
std::string flatten_linear_pattern = R"IR(
13-
graph(%input, %6, %7, %weight, %bias):
14-
%flat = aten::flatten(%input, %6, %7)
15-
%res = aten::linear(%flat, %weight, %bias)
13+
graph(%input, %weight, %bias):
14+
%res = aten::linear(%input, %weight, %bias)
1615
return (%res))IR";
1716
std::string flatten_linear_bias_none_pattern = R"IR(
18-
graph(%input, %6, %7, %weight):
19-
%flat = aten::flatten(%input, %6, %7)
17+
graph(%input, %weight):
2018
%bias: Tensor? = prim::Constant()
21-
%res = aten::linear(%flat, %weight, %bias)
22-
return (%res))IR";
23-
std::string fused_linear = R"IR(
24-
graph(%input, %6, %7, %weight, %bias):
2519
%res = aten::linear(%input, %weight, %bias)
2620
return (%res))IR";
2721

22+
std::string fused_linear = R"IR(
23+
graph(%input, %weight_t, %bias):
24+
%1: int = prim::Constant[value=1]()
25+
%weight = aten::t(%weight_t)
26+
%mm: Tensor = aten::matmul(%input, %weight)
27+
%b_f: Tensor = trt::const(%bias)
28+
%out: Tensor = aten::add_(%b_f, %mm, %1)
29+
return (%out))IR";
2830
std::string fused_linear_bias_none = R"IR(
29-
graph(%input, %6, %7, %weight):
30-
%bias: Tensor? = prim::Constant()
31-
%res = aten::linear(%input, %weight, %bias)
32-
return (%res))IR";
31+
graph(%input, %weight_t):
32+
%weight = aten::t(%weight_t)
33+
%mm: Tensor = aten::matmul(%input, %weight)
34+
return (%mm))IR";
3335

3436
torch::jit::SubgraphRewriter flatten_linear_to_linear;
3537
flatten_linear_to_linear.RegisterRewritePattern(flatten_linear_pattern, fused_linear);
@@ -38,7 +40,7 @@ void FuseFlattenLinear(std::shared_ptr<torch::jit::Graph>& graph) {
3840
torch::jit::SubgraphRewriter flatten_linear_bias_none_to_linear;
3941
flatten_linear_bias_none_to_linear.RegisterRewritePattern(flatten_linear_bias_none_pattern, fused_linear_bias_none);
4042
flatten_linear_bias_none_to_linear.runOnGraph(graph);
41-
LOG_GRAPH("Post flatten linear: " << *graph);
43+
LOG_GRAPH("Post linear to addmm: " << *graph);
4244
}
4345

4446
} // namespace passes

0 commit comments

Comments
 (0)