Skip to content

Commit d73738c

Browse files
committed
merge master
Signed-off-by: Michael Feliz <[email protected]>
2 parents 3046a36 + f5aa404 commit d73738c

File tree

443 files changed

+39768
-2218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

443 files changed

+39768
-2218
lines changed

.circleci/config.yml

Lines changed: 1023 additions & 0 deletions
Large diffs are not rendered by default.

.github/code-owners.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,17 @@
110110
- "peri044"
111111
- "bowang007"
112112

113-
"component: docker":
113+
"channel: docker":
114114
- "andi4191"
115115
- "narendasan"
116116

117-
"component: ux":
117+
"ux":
118118
# Issues related to the user experience including debugging and installation
119119
- "narendasan"
120120
- "peri044"
121121

122+
"component: fx":
123+
- "frank-wei"
124+
- "yinghai"
125+
- "842974287"
126+
- "wushirong"

.github/pr-labels.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818

1919
"component: evaluators":
2020
- core/conversion/evaluators/**/*
21+
22+
"component: fx":
23+
- py/torch_tensorrt/fx/**/*
2124

2225
"component: partitioning":
2326
- core/partitioning/**/*

.github/pull_request_template.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ Please delete options that are not relevant and/or add your own.
2020
- [ ] I have commented my code, particularly in hard-to-understand areas and hacks
2121
- [ ] I have made corresponding changes to the documentation
2222
- [ ] I have added tests to verify my fix or my feature
23-
- [ ] New and existing unit tests pass locally with my changes
23+
- [ ] New and existing unit tests pass locally with my changes
24+
- [ ] I have added the relevant labels to my PR in so that relevant reviewers are notified

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,6 @@ bazel-Torch-TensorRT-Preview
6262
docsrc/src/
6363
bazel-TensorRT
6464
bazel-tensorrt
65+
.pytest_cache
66+
*.cache
67+
*cifar-10-batches-py*

CMakeLists.txt

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
cmake_minimum_required(VERSION 3.17)
3+
project(Torch-TensorRT LANGUAGES CXX)
4+
5+
# use c++17
6+
set(CMAKE_CXX_STANDARD 17)
7+
8+
# Build the libraries with -fPIC
9+
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
10+
11+
if (DEFINED CMAKE_MODULE_PATH)
12+
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} CACHE PATH "Path to the folder containing finders")
13+
endif()
14+
15+
include(cmake/build_options.cmake)
16+
include(cmake/paths.cmake)
17+
include(cmake/dependencies.cmake)
18+
if(MSVC)
19+
add_compile_options(/wd4624 /wd4067 /permissive-)
20+
# When using Ninja generator, suppress the warning D9025
21+
string(REPLACE "/Zi" "/Z7" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
22+
string(REPLACE "/Zi" "/Z7" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
23+
endif()
24+
# -----------------------------------------
25+
# compilation
26+
# -----------------------------------------
27+
add_subdirectory(core)
28+
add_subdirectory(cpp)
29+
30+
include(CMakePackageConfigHelpers)
31+
32+
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
33+
"${CMAKE_CURRENT_BINARY_DIR}/torchtrtConfig.cmake"
34+
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/torchtrt
35+
)
36+
37+
install(FILES
38+
"${CMAKE_CURRENT_BINARY_DIR}/torchtrtConfig.cmake"
39+
# "${CMAKE_CURRENT_BINARY_DIR}/torchtrtConfigVersion.cmake"
40+
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/torchtrt
41+
)

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Developing Torch-TensorRT
44

5-
Do try to fill an issue with your feature or bug before filling a PR (op support is generally an exception as long as you provide tests to prove functionality). There is also a backlog (https://github.com/NVIDIA/Torch-TensorRT/issues) of issues which are tagged with the area of focus, a coarse priority level and whether the issue may be accessible to new contributors. Let us know if you are interested in working on a issue. We are happy to provide guidance and mentorship for new contributors. Though note, there is no claiming of issues, we prefer getting working code quickly vs. addressing concerns about "wasted work".
5+
Do try to fill an issue with your feature or bug before filling a PR (op support is generally an exception as long as you provide tests to prove functionality). There is also a backlog (https://github.com/pytorch/TensorRT/issues) of issues which are tagged with the area of focus, a coarse priority level and whether the issue may be accessible to new contributors. Let us know if you are interested in working on a issue. We are happy to provide guidance and mentorship for new contributors. Though note, there is no claiming of issues, we prefer getting working code quickly vs. addressing concerns about "wasted work".
66

77
#### Communication
88

Config.cmake.in

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@PACKAGE_INIT@
2+
3+
include(CMakeFindDependencyMacro)
4+
5+
find_dependency(Torch)
6+
find_package(TensorRT QUIET)
7+
if (NOT TensorRT_FOUND)
8+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/Modules")
9+
find_dependency(TensorRT)
10+
endif()
11+
include("${CMAKE_CURRENT_LIST_DIR}/torchtrtTargets.cmake")
12+
13+
check_required_components(MathFunctions)

LICENSE

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
Copyright (c) 2020-present, NVIDIA CORPORATION. All rights reserved.
2+
Copyright (c) Meta Platforms, Inc. and affiliates.
3+
24

35
Redistribution and use in source and binary forms, with or without
46
modification, are permitted provided that the following conditions
@@ -11,9 +13,9 @@ are met:
1113
notice, this list of conditions and the following disclaimer in the
1214
documentation and/or other materials provided with the distribution.
1315

14-
3. Neither the name of NVIDIA CORPORATION nor the names of its
15-
contributors may be used to endorse or promote products derived
16-
from this software without specific prior written permission.
16+
3. Neither the name of the copyright holder nor the names of its contributors
17+
may be used to endorse or promote products derived from this software
18+
without specific prior written permission.
1719

1820
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
1921
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -25,4 +27,4 @@ PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
2527
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
2628
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
2729
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28-
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 52 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22

33
[![Documentation](https://img.shields.io/badge/docs-master-brightgreen)](https://nvidia.github.io/Torch-TensorRT/)
44

5-
> Ahead of Time (AOT) compiling for PyTorch JIT
5+
> Ahead of Time (AOT) compiling for PyTorch JIT and FX
66
7-
Torch-TensorRT is a compiler for PyTorch/TorchScript, targeting NVIDIA GPUs via NVIDIA's TensorRT Deep Learning Optimizer and Runtime. Unlike PyTorch's Just-In-Time (JIT) compiler, Torch-TensorRT is an Ahead-of-Time (AOT) compiler, meaning that before you deploy your TorchScript code, you go through an explicit compile step to convert a standard TorchScript program into an module targeting a TensorRT engine. Torch-TensorRT operates as a PyTorch extention and compiles modules that integrate into the JIT runtime seamlessly. After compilation using the optimized graph should feel no different than running a TorchScript module. You also have access to TensorRT's suite of configurations at compile time, so you are able to specify operating precision (FP32/FP16/INT8) and other settings for your module.
7+
Torch-TensorRT is a compiler for PyTorch/TorchScript/FX, targeting NVIDIA GPUs via NVIDIA's TensorRT Deep Learning Optimizer and Runtime. Unlike PyTorch's Just-In-Time (JIT) compiler, Torch-TensorRT is an Ahead-of-Time (AOT) compiler, meaning that before you deploy your TorchScript code, you go through an explicit compile step to convert a standard TorchScript or FX program into an module targeting a TensorRT engine. Torch-TensorRT operates as a PyTorch extention and compiles modules that integrate into the JIT runtime seamlessly. After compilation using the optimized graph should feel no different than running a TorchScript module. You also have access to TensorRT's suite of configurations at compile time, so you are able to specify operating precision (FP32/FP16/INT8) and other settings for your module.
88

99
Resources:
1010
- [Documentation](https://nvidia.github.io/Torch-TensorRT/)
11-
- [Torch-TensorRT Explained in 2 minutes!](https://www.youtube.com/watch?v=TU5BMU6iYZ0&ab_channel=NVIDIADeveloper)
11+
- [FX path Documentation](https://github.com/pytorch/TensorRT/blob/master/docsrc/tutorials/getting_started_with_fx_path.rst)
12+
- [Torch-TensorRT Explained in 2 minutes!](https://www.youtube.com/watch?v=TU5BMU6iYZ0&ab_channel=NVIDIADeveloper)
1213
- [Comprehensive Discusion (GTC Event)](https://www.nvidia.com/en-us/on-demand/session/gtcfall21-a31107/)
1314
- [Pre-built Docker Container](https://catalog.ngc.nvidia.com/orgs/nvidia/containers/pytorch). To use this container, make an NGC account and sign in to NVIDIA's registry with an API key. Refer to [this guide](https://docs.nvidia.com/ngc/ngc-catalog-user-guide/index.html#registering-activating-ngc-account) for the same.
1415

@@ -111,14 +112,14 @@ torch.jit.save(trt_ts_module, "trt_torchscript_module.ts") # save the TRT embedd
111112
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.
112113

113114
- Bazel 5.1.1
114-
- Libtorch 1.11.0 (built with CUDA 11.3)
115+
- Libtorch 1.12.0 (built with CUDA 11.3)
115116
- CUDA 11.3
116-
- cuDNN 8.2.1
117-
- TensorRT 8.2.4.2
117+
- cuDNN 8.4.1
118+
- TensorRT 8.4.1.5
118119

119120
## Prebuilt Binaries and Wheel files
120121

121-
Releases: https://github.com/NVIDIA/Torch-TensorRT/releases
122+
Releases: https://github.com/pytorch/TensorRT/releases
122123

123124
## Compiling Torch-TensorRT
124125

@@ -212,6 +213,12 @@ new_local_repository(
212213
bazel build //:libtorchtrt --compilation_mode opt
213214
```
214215

216+
### FX path (Python only) installation
217+
If the user plans to try FX path (Python only) and would like to avoid bazel build. Please follow the steps below.
218+
``` shell
219+
cd py && python3 setup.py install --fx-only
220+
```
221+
215222
### Debug build
216223

217224
``` shell
@@ -250,11 +257,48 @@ docker run -it -v$(pwd)/..:/workspace/Torch-TensorRT build_torch_tensorrt_wheel
250257

251258
Python compilation expects using the tarball based compilation strategy from above.
252259

260+
261+
## Testing using Python backend
262+
263+
Torch-TensorRT supports testing in Python using [nox](https://nox.thea.codes/en/stable)
264+
265+
To install the nox using python-pip
266+
267+
```
268+
python3 -m pip install --upgrade nox
269+
```
270+
271+
To list supported nox sessions:
272+
273+
```
274+
nox --session -l
275+
```
276+
277+
Environment variables supported by nox
278+
279+
```
280+
PYT_PATH - To use different PYTHONPATH than system installed Python packages
281+
TOP_DIR - To set the root directory of the noxfile
282+
USE_CXX11 - To use cxx11_abi (Defaults to 0)
283+
USE_HOST_DEPS - To use host dependencies for tests (Defaults to 0)
284+
```
285+
286+
Usage example
287+
288+
```
289+
nox --session l0_api_tests
290+
```
291+
292+
Supported Python versions:
293+
```
294+
["3.7", "3.8", "3.9", "3.10"]
295+
```
296+
253297
## How do I add support for a new op...
254298

255299
### In Torch-TensorRT?
256300

257-
Thanks for wanting to contribute! There are two main ways to handle supporting a new op. Either you can write a converter for the op from scratch and register it in the NodeConverterRegistry or if you can map the op to a set of ops that already have converters you can write a graph rewrite pass which will replace your new op with an equivalent subgraph of supported ops. Its preferred to use graph rewriting because then we do not need to maintain a large library of op converters. Also do look at the various op support trackers in the [issues](https://github.com/NVIDIA/Torch-TensorRT/issues) for information on the support status of various operators.
301+
Thanks for wanting to contribute! There are two main ways to handle supporting a new op. Either you can write a converter for the op from scratch and register it in the NodeConverterRegistry or if you can map the op to a set of ops that already have converters you can write a graph rewrite pass which will replace your new op with an equivalent subgraph of supported ops. Its preferred to use graph rewriting because then we do not need to maintain a large library of op converters. Also do look at the various op support trackers in the [issues](https://github.com/pytorch/TensorRT/issues) for information on the support status of various operators.
258302

259303
### In my application?
260304

WORKSPACE

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,17 +56,17 @@ new_local_repository(
5656
http_archive(
5757
name = "libtorch",
5858
build_file = "@//third_party/libtorch:BUILD",
59-
sha256 = "8d9e829ce9478db4f35bdb7943308cf02e8a2f58cf9bb10f742462c1d57bf287",
59+
sha256 = "80f089939de20e68e3fcad4dfa72a26c8bf91b5e77b11042f671f39ebac35865",
6060
strip_prefix = "libtorch",
61-
urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.11.0%2Bcu113.zip"],
61+
urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-cxx11-abi-shared-with-deps-1.12.0%2Bcu113.zip"],
6262
)
6363

6464
http_archive(
6565
name = "libtorch_pre_cxx11_abi",
6666
build_file = "@//third_party/libtorch:BUILD",
67-
sha256 = "90159ecce3ff451f3ef3f657493b6c7c96759c3b74bbd70c1695f2ea2f81e1ad",
67+
sha256 = "8e35371403f7052d9e9b43bcff383980dbde4df028986dc1dab539953481d55f",
6868
strip_prefix = "libtorch",
69-
urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.11.0%2Bcu113.zip"],
69+
urls = ["https://download.pytorch.org/libtorch/cu113/libtorch-shared-with-deps-1.12.0%2Bcu113.zip"],
7070
)
7171

7272
# Download these tarballs manually from the NVIDIA website
@@ -76,20 +76,20 @@ http_archive(
7676
http_archive(
7777
name = "cudnn",
7878
build_file = "@//third_party/cudnn/archive:BUILD",
79-
sha256 = "0e5d2df890b9967efa6619da421310d97323565a79f05a1a8cb9b7165baad0d7",
80-
strip_prefix = "cuda",
79+
sha256 = "ec96d2376d81fca42bdd3d4c3d705a99b29a065bab57f920561c763e29c67d01",
80+
strip_prefix = "cudnn-linux-x86_64-8.4.1.50_cuda11.6-archive",
8181
urls = [
82-
"https://developer.nvidia.com/compute/machine-learning/cudnn/secure/8.2.4/11.4_20210831/cudnn-11.4-linux-x64-v8.2.4.15.tgz",
82+
"https://developer.nvidia.com/compute/cudnn/secure/8.4.1/local_installers/11.6/cudnn-linux-x86_64-8.4.1.50_cuda11.6-archive.tar.xz",
8383
],
8484
)
8585

8686
http_archive(
8787
name = "tensorrt",
8888
build_file = "@//third_party/tensorrt/archive:BUILD",
89-
sha256 = "826180eaaecdf9a7e76116855b9f1f3400ea9b06e66b06a3f6a0747ba6f863ad",
90-
strip_prefix = "TensorRT-8.2.4.2",
89+
sha256 = "8107861af218694130f170e071f49814fa3e27f1386ce7cb6d807ac05a7fcf0e",
90+
strip_prefix = "TensorRT-8.4.1.5",
9191
urls = [
92-
"https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/8.2.4/tars/tensorrt-8.2.4.2.linux.x86_64-gnu.cuda-11.4.cudnn8.2.tar.gz",
92+
"https://developer.nvidia.com/compute/machine-learning/tensorrt/secure/8.4.1/tars/tensorrt-8.4.1.5.linux.x86_64-gnu.cuda-11.6.cudnn8.4.tar.gz",
9393
],
9494
)
9595

0 commit comments

Comments
 (0)