From c009a1fc5167a9b85818aa94d2a67c9a650b6070 Mon Sep 17 00:00:00 2001 From: Dheeraj Peri Date: Wed, 6 Apr 2022 14:54:59 -0700 Subject: [PATCH] feat: Update Pytorch version to 1.11 Signed-off-by: Dheeraj Peri --- README.md | 2 +- WORKSPACE | 8 ++++---- core/conversion/evaluators/eval_util.cpp | 3 ++- core/lowering/passes/linear_to_addmm.cpp | 6 +++--- core/partitioning/shape_analysis.cpp | 1 + py/requirements.txt | 2 +- tests/cpp/test_modules_as_engines.cpp | 2 +- tests/modules/requirements.txt | 2 +- tests/py/requirements.txt | 2 +- tests/util/util.h | 2 +- third_party/libtorch/BUILD | 5 ----- 11 files changed, 16 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 54dbcaf72f..2e8270b3a9 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ torch.jit.save(trt_ts_module, "trt_torchscript_module.ts") # save the TRT embedd These are the following dependencies used to verify the testcases. Torch-TensorRT can work with other versions, but the tests are not guaranteed to pass. - Bazel 4.2.1 -- Libtorch 1.10.0 (built with CUDA 11.3) +- Libtorch 1.11.0 (built with CUDA 11.3) - CUDA 11.3 (10.2 on Jetson) - cuDNN 8.2.1 - TensorRT 8.2.4.2 (TensorRT 8.2.1 on Jetson) diff --git a/WORKSPACE b/WORKSPACE index a9fb45f371..2779e93cc7 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -56,17 +56,17 @@ new_local_repository( http_archive( name = "libtorch", build_file = "@//third_party/libtorch:BUILD", - sha256 = "190e963e739d5f7c2dcf94b3994de8fcd335706a4ebb333812ea7d8c841beb06", + sha256 = "8d9e829ce9478db4f35bdb7943308cf02e8a2f58cf9bb10f742462c1d57bf287", strip_prefix = "libtorch", - urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.10.0%2Bcu113.zip"], + urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.11.0%2Bcu113.zip"], ) http_archive( name = "libtorch_pre_cxx11_abi", build_file = "@//third_party/libtorch:BUILD", - sha256 = "0996a6a4ea8bbc1137b4fb0476eeca25b5efd8ed38955218dec1b73929090053", + sha256 = "90159ecce3ff451f3ef3f657493b6c7c96759c3b74bbd70c1695f2ea2f81e1ad", strip_prefix = "libtorch", - urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.10.0%2Bcu113.zip"], + urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.11.0%2Bcu113.zip"], ) # Download these tarballs manually from the NVIDIA website diff --git a/core/conversion/evaluators/eval_util.cpp b/core/conversion/evaluators/eval_util.cpp index dc0503886e..cb294fc1c8 100644 --- a/core/conversion/evaluators/eval_util.cpp +++ b/core/conversion/evaluators/eval_util.cpp @@ -1,3 +1,4 @@ +#include #include "ATen/InitialTensorOptions.h" #include "ATen/core/List.h" #include "ATen/core/functional.h" @@ -238,7 +239,7 @@ at::Tensor createTensorFromList( /// Gets shape of tensor to be created auto sizes = compute_sizes(data); checkListInputType(elem_type, sizes.size() == 1 && sizes[0] == 0); - at::ScalarType initial_scalar_type = c10::scalarTypeFromJitType(elem_type); + at::ScalarType initial_scalar_type = c10::scalarTypeFromJitType(*elem_type); if (initial_scalar_type == at::ScalarType::Double) { initial_scalar_type = at::typeMetaToScalarType(c10::get_default_dtype()); } diff --git a/core/lowering/passes/linear_to_addmm.cpp b/core/lowering/passes/linear_to_addmm.cpp index 15a035f59c..c3160a8757 100644 --- a/core/lowering/passes/linear_to_addmm.cpp +++ b/core/lowering/passes/linear_to_addmm.cpp @@ -7,9 +7,9 @@ #include "torch/csrc/jit/passes/guard_elimination.h" #include "torch/csrc/jit/passes/peephole.h" #include "torch/csrc/jit/runtime/graph_executor.h" - -#include "core/util/prelude.h" +#include "torch/csrc/jit/api/function_impl.h" #include "torch/csrc/jit/passes/subgraph_rewrite.h" +#include "core/util/prelude.h" namespace torch_tensorrt { namespace core { @@ -34,7 +34,7 @@ void replaceLinearWithBiasNonePattern(std::shared_ptr graph) continue; } else { torch::jit::WithInsertPoint guard(*it); - std::shared_ptr d_graph = decompose_funcs.get_function("linear").graph(); + std::shared_ptr d_graph = toGraphFunction(decompose_funcs.get_function("linear")).graph();; torch::jit::Value* new_output = insertGraph(*it->owningGraph(), *d_graph, it->inputs()).at(0); new_output->setType(it->output()->type()); it->output()->replaceAllUsesWith(new_output); diff --git a/core/partitioning/shape_analysis.cpp b/core/partitioning/shape_analysis.cpp index e2e2bfe150..92ce1dd041 100644 --- a/core/partitioning/shape_analysis.cpp +++ b/core/partitioning/shape_analysis.cpp @@ -1,3 +1,4 @@ +#include #include "core/partitioning/shape_analysis.h" #include "core/util/prelude.h" #include "torch/csrc/jit/api/module.h" diff --git a/py/requirements.txt b/py/requirements.txt index 110b76e1ee..097a3292f3 100644 --- a/py/requirements.txt +++ b/py/requirements.txt @@ -1,3 +1,3 @@ -f https://download.pytorch.org/whl/torch_stable.html -torch==1.10.0+cu113 +torch==1.11.0+cu113 pybind11==2.6.2 diff --git a/tests/cpp/test_modules_as_engines.cpp b/tests/cpp/test_modules_as_engines.cpp index ab4ccc1ae7..269e3ea1b8 100644 --- a/tests/cpp/test_modules_as_engines.cpp +++ b/tests/cpp/test_modules_as_engines.cpp @@ -63,7 +63,7 @@ INSTANTIATE_TEST_SUITE_P( PathAndInSize({"tests/modules/resnet18_scripted.jit.pt", {{1, 3, 224, 224}}, 2e-5}), PathAndInSize({"tests/modules/resnet50_scripted.jit.pt", {{1, 3, 224, 224}}, 2e-5}), PathAndInSize({"tests/modules/mobilenet_v2_scripted.jit.pt", {{1, 3, 224, 224}}, 2e-5}), - PathAndInSize({"tests/modules/efficientnet_b0_scripted.jit.pt", {{1, 3, 224, 224}}, 2e-5}), + PathAndInSize({"tests/modules/efficientnet_b0_scripted.jit.pt", {{1, 3, 224, 224}}, 1e-4}), PathAndInSize({"tests/modules/vit_scripted.jit.pt", {{1, 3, 224, 224}}, 8e-2}))); #endif diff --git a/tests/modules/requirements.txt b/tests/modules/requirements.txt index c7eb11119d..6dc21e0803 100644 --- a/tests/modules/requirements.txt +++ b/tests/modules/requirements.txt @@ -1,3 +1,3 @@ -f https://download.pytorch.org/whl/torch_stable.html timm==v0.4.12 -torch==1.10.0+cu113 +torch==1.11.0+cu113 diff --git a/tests/py/requirements.txt b/tests/py/requirements.txt index 7480c8d980..91e97eed3e 100644 --- a/tests/py/requirements.txt +++ b/tests/py/requirements.txt @@ -1,2 +1,2 @@ -torchvision==0.11.1+cu113 +torchvision==0.12.0+cu113 -f https://download.pytorch.org/whl/torch_stable.html diff --git a/tests/util/util.h b/tests/util/util.h index 287b736665..38ba81e73d 100644 --- a/tests/util/util.h +++ b/tests/util/util.h @@ -2,7 +2,7 @@ #include #include - +#include #include "ATen/Tensor.h" #include "core/ir/ir.h" #include "core/util/prelude.h" diff --git a/third_party/libtorch/BUILD b/third_party/libtorch/BUILD index 9db090b2a7..1b0a8fe266 100644 --- a/third_party/libtorch/BUILD +++ b/third_party/libtorch/BUILD @@ -90,14 +90,9 @@ cc_library( srcs = select({ ":windows": [ "lib/caffe2_nvrtc.lib", - "lib/caffe2_detectron_ops_gpu.lib", - "lib/caffe2_module_test_dynamic.lib", ], "//conditions:default": [ "lib/libcaffe2_nvrtc.so", - "lib/libcaffe2_detectron_ops_gpu.so", - "lib/libcaffe2_observers.so", - "lib/libcaffe2_module_test_dynamic.so", ], }), hdrs = glob([