Skip to content

Commit 1f2ffc4

Browse files
committed
Merge branch 'master' into aten_to
2 parents 69aabee + 8f1f9cd commit 1f2ffc4

File tree

15 files changed

+137
-77
lines changed

15 files changed

+137
-77
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,7 @@ py/wheelhouse
4040
py/.eggs
4141
notebooks/.ipynb_checkpoints/
4242
*.cache
43-
tests/py/data
43+
tests/py/data
44+
examples/**/deps/**/*
45+
!examples/**/deps/.gitkeep
46+
examples/trtorchrt_example/trtorchrt_example

core/plugins/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ On a high level, TRTorch plugin library interface does the following :
66

77
- Uses TensorRT plugin registry as the main data structure to access all plugins.
88

9-
- Automatically registers TensorRT plugins with empty namepsace.
9+
- Automatically registers TensorRT plugins with empty namepsace.
1010

1111
- Automatically registers TRTorch plugins with `"trtorch"` namespace.
1212

@@ -37,4 +37,4 @@ If you'd like to compile your plugin with TRTorch,
3737

3838
Once you've completed the above steps, upon successful compilation of TRTorch library, your plugin should be available in `libtrtorch_plugins.so`.
3939

40-
A sample runtime application on how to run a network with plugins can be found <a href="https://github.com/NVIDIA/TRTorch/tree/master/examples/sample_rt_app" >here</a>
40+
A sample runtime application on how to run a network with plugins can be found <a href="https://github.com/NVIDIA/TRTorch/tree/master/examples/trtorchrt_example" >here</a>

cpp/trtorchc/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,8 @@ trtorchc [input_file_path] [output_file_path]
5959
--dla-core=[dla_core] DLACore id if running on available DLA
6060
(defaults to 0)
6161
--engine-capability=[capability] The type of device the engine should be
62-
built for [ default | safe_gpu |
63-
safe_dla ]
62+
built for [ standard | safety |
63+
dla_standalone ]
6464
--calibration-cache-file=[file_path]
6565
Path to calibration cache file to use
6666
for post training quantization

cpp/trtorchc/main.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ int main(int argc, char** argv) {
264264
args::ValueFlag<std::string> engine_capability(
265265
parser,
266266
"capability",
267-
"The type of device the engine should be built for [ default | safe_gpu | safe_dla ]",
267+
"The type of device the engine should be built for [ standard | safety | dla_standalone ]",
268268
{"engine-capability"});
269269

270270
args::ValueFlag<std::string> calibration_cache_file(
@@ -537,12 +537,12 @@ int main(int argc, char** argv) {
537537
auto capability = args::get(engine_capability);
538538
std::transform(
539539
capability.begin(), capability.end(), capability.begin(), [](unsigned char c) { return std::tolower(c); });
540-
if (capability == "default") {
541-
compile_settings.capability = trtorch::CompileSpec::EngineCapability::kDEFAULT;
542-
} else if (capability == "safe_gpu") {
543-
compile_settings.capability = trtorch::CompileSpec::EngineCapability::kSAFE_GPU;
544-
} else if (capability == "safe_dla") {
545-
compile_settings.capability = trtorch::CompileSpec::EngineCapability::kSAFE_DLA;
540+
if (capability == "standard") {
541+
compile_settings.capability = trtorch::CompileSpec::EngineCapability::kSTANDARD;
542+
} else if (capability == "safety") {
543+
compile_settings.capability = trtorch::CompileSpec::EngineCapability::kSAFETY;
544+
} else if (capability == "dla_standalone") {
545+
compile_settings.capability = trtorch::CompileSpec::EngineCapability::kDLA_STANDALONE;
546546
} else {
547547
trtorch::logging::log(
548548
trtorch::logging::Level::kERROR, "Invalid engine capability, options are [ default | safe_gpu | safe_dla ]");

docsrc/RELEASE_CHECKLIST.md

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ will result in a minor version bump and sigificant bug fixes will result in a pa
2121
- All checked in applications (cpp and python) should compile and work
2222
3. Generate new index of converters and evalutators
2323
- `bazel run //tools/supportedops -- <PATH TO TRTORCH>/docsrc/indices/supported_ops.rst`
24-
3. Version bump PR
24+
4. Version bump PR
2525
- There should be a PR which will be the PR that bumps the actual version of the library, this PR should contain the following
2626
- Bump version in `py/setup.py`
2727
- Make sure dependency versions are updated in `py/requirements.txt`, `tests/py/requirements.txt` and `py/setup.py`
@@ -34,7 +34,29 @@ will result in a minor version bump and sigificant bug fixes will result in a pa
3434
- `make html`
3535
- Generate changelog
3636
- `conventional-changelog -p angular -s -i CHANGELOG.md -t <last version tag> -a`
37-
4. Once PR is merged tag commit and start creating release on GitHub
37+
38+
5. Run performance tests:
39+
- Models:
40+
- Torchbench BERT
41+
- `[2, 128], [2, 128]`
42+
- EfficientNet B0
43+
- `[3, 224, 224]`
44+
- `[3, 1920, 1080]` (P2)
45+
- ViT
46+
- `[3, 224, 224]`
47+
- `[3, 1920, 1080]` (P2)
48+
- ResNet50 (v1.5 ?)
49+
- `[3, 224, 224]`
50+
- `[3, 1920, 1080]` (P2)
51+
- Batch Sizes: 1, 4, 8, 16, 32
52+
- Frameworks: PyTorch, TRTorch, ONNX + TRT
53+
- If any models do not convert to ONNX / TRT, that is fine. Mark them as failling / no result
54+
- Devices:
55+
- A100 (P0)
56+
- T4 is a nice to have (P2) (Add batch sizes 64, 128, 256, 512, 1024 if so)
57+
- Jetson also nice to have (P4)
58+
59+
6. Once PR is merged tag commit and start creating release on GitHub
3860
- Paste in Milestone information and Changelog information into release notes
3961
- Generate libtrtorch.tar.gz for the following platforms:
4062
- x86_64 cxx11-abi
@@ -43,4 +65,4 @@ will result in a minor version bump and sigificant bug fixes will result in a pa
4365
- Generate Python packages for Python 3.6/3.7/3.8/3.9 for x86_64
4466
- TODO: Build a manylinux container for aarch64
4567
- `docker run -it -v$(pwd)/..:/workspace/TRTorch build_trtorch_wheel /bin/bash /workspace/TRTorch/py/build_whl.sh` generates all wheels
46-
- To build container `docker build -t build_trtorch_wheel .`
68+
- To build container `docker build -t build_trtorch_wheel .`

docsrc/tutorials/runtime.rst

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,15 @@ link ``libtrtorchrt.so`` in your deployment programs or use ``DL_OPEN`` or ``LD_
2222
you can load the runtime with ``torch.ops.load_library("libtrtorchrt.so")``. You can then continue to use
2323
programs just as you would otherwise via PyTorch API.
2424

25-
.. note:: If you are using the standard distribution of PyTorch in Python on x86, likely you will need the pre-cxx11-abi variant of ``libtrtorchrt.so``, check :ref:`Installation` documentation for more details.
25+
.. note:: If you are using the standard distribution of PyTorch in Python on x86, likely you will need the pre-cxx11-abi variant of ``libtrtorchrt.so``, check :ref:`Installation` documentation for more details.
26+
27+
.. note:: If you are linking ``libtrtorchrt.so``, likely using the following flags will help ``-Wl,--no-as-needed -ltrtorchrt -Wl,--as-needed`` as theres no direct symbol dependency to anything in the TRTorch runtime for most TRTorch runtime applications
28+
29+
An example of how to use ``libtrtorchrt.so`` can be found here: https://github.com/NVIDIA/TRTorch/tree/master/examples/trtorchrt_example
30+
31+
Plugin Library
32+
---------------
33+
34+
In the case you use TRTorch as a converter to a TensorRT engine and your engine uses plugins provided by TRTorch, TRTorch
35+
ships the library ``libtrtorch_plugins.so`` which contains the implementation of the TensorRT plugins used by TRTorch during
36+
compilation. This library can be ``DL_OPEN`` or ``LD_PRELOAD`` similar to other TensorRT plugin libraries.

docsrc/tutorials/trtorchc.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ to standard TorchScript. Load with ``torch.jit.load()`` and run like you would r
4545
--ffo,
4646
--forced-fallback-ops List of operators in the graph that
4747
should be forced to fallback to Pytorch for execution
48-
48+
4949
--disable-tf32 Prevent Float32 layers from using the
5050
TF32 data format
5151
-p[precision...],
@@ -55,16 +55,16 @@ to standard TorchScript. Load with ``torch.jit.load()`` and run like you would r
5555
calibration-cache argument) [ float |
5656
float32 | f32 | half | float16 | f16 |
5757
int8 | i8 ] (default: float)
58-
58+
5959
-d[type], --device-type=[type] The type of device the engine should be
6060
built for [ gpu | dla ] (default: gpu)
6161
--gpu-id=[gpu_id] GPU id if running on multi-GPU platform
6262
(defaults to 0)
6363
--dla-core=[dla_core] DLACore id if running on available DLA
6464
(defaults to 0)
6565
--engine-capability=[capability] The type of device the engine should be
66-
built for [ default | safe_gpu |
67-
safe_dla ]
66+
built for [ standard | safety |
67+
dla_standalone ]
6868
--calibration-cache-file=[file_path]
6969
Path to calibration cache file to use
7070
for post training quantization

examples/sample_rt_app/BUILD

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/sample_rt_app/README.md

Lines changed: 0 additions & 36 deletions
This file was deleted.

examples/trtorchrt_example/BUILD

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package(default_visibility = ["//visibility:public"])
2+
3+
cc_binary(
4+
name = "trtorchrt_example",
5+
srcs = [
6+
"main.cpp"
7+
],
8+
deps = [
9+
"//core/runtime:runtime",
10+
"@libtorch//:libtorch",
11+
"@libtorch//:caffe2",
12+
"@tensorrt//:nvinfer",
13+
],
14+
)

examples/trtorchrt_example/Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
CXX=g++
2+
DEP_DIR=$(PWD)/deps
3+
INCLUDE_DIRS=-I$(DEP_DIR)/libtorch/include -I$(DEP_DIR)/trtorch/include
4+
LIB_DIRS=-L$(DEP_DIR)/trtorch/lib -L$(DEP_DIR)/libtorch/lib # -Wl,-rpath $(DEP_DIR)/tensorrt/lib -Wl,-rpath $(DEP_DIR)/cudnn/lib64
5+
LIBS=-Wl,--no-as-needed -ltrtorchrt -Wl,--as-needed -ltorch -ltorch_cuda -ltorch_cpu -ltorch_global_deps -lbackend_with_compiler -lc10 -lc10_cuda
6+
SRCS=main.cpp
7+
8+
TARGET=trtorchrt_example
9+
10+
$(TARGET):
11+
$(CXX) $(SRCS) $(INCLUDE_DIRS) $(LIB_DIRS) $(LIBS) -o $(TARGET)
12+
13+
clean:
14+
$(RM) $(TARGET)

examples/trtorchrt_example/README.md

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# trtorchrt_example
2+
3+
## Sample application which uses TRTorch runtime library and plugin library.
4+
5+
This sample is a demonstration on how to use TRTorch runtime library `libtrtorchrt.so` along with plugin library `libtrtorch_plugins.so`
6+
7+
In this demo, we convert two models `ConvGelu` and `Norm` to TensorRT using TRTorch python API and perform inference using `samplertapp`. In these models, `Gelu` and `Norm` layer are expressed as plugins in the network.
8+
9+
### Generating Torch script modules with TRT Engines
10+
11+
The following command will generate `conv_gelu.jit` and `norm.jit` torchscript modules which contain TensorRT engines.
12+
13+
```sh
14+
python network.py
15+
```
16+
17+
### `trtorchrt_example`
18+
The main goal is to use TRTorch runtime library `libtrtorchrt.so`, a lightweight library sufficient enough to deploy your Torchscript programs containing TRT engines.
19+
20+
1) Download releases of LibTorch and TRTorch from https://pytorch.org and the TRTorch github repo and unpack both in the deps directory.
21+
22+
```sh
23+
cd examples/trtorchrt_example/deps
24+
// Download latest TRTorch release tar file (libtrtorch.tar.gz) from https://github.com/NVIDIA/TRTorch/releases
25+
tar -xvzf libtrtorch.tar.gz
26+
unzip libtorch-cxx11-abi-shared-with-deps-1.9.0+cu111.zip
27+
```
28+
29+
> If cuDNN and TensorRT are not installed on your system / in your LD_LIBRARY_PATH then do the following as well
30+
31+
```sh
32+
cd deps
33+
mkdir cudnn && tar -xvzf <cuDNN TARBALL> --directory cudnn --strip-components=1
34+
mkdir tensorrt && tar -xvzf <TensorRT TARBALL> --directory tensorrt --strip-components=1
35+
cd ..
36+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/deps/trtorch/lib:$(pwd)/deps/libtorch/lib:$(pwd)/deps/tensorrt/lib:$(pwd)/deps/cudnn/lib64:/usr/local/cuda/lib
37+
```
38+
39+
This gives maximum compatibility with system configurations for running this example but in general you are better off adding `-Wl,-rpath $(DEP_DIR)/tensorrt/lib -Wl,-rpath $(DEP_DIR)/cudnn/lib64` to your linking command for actual applications
40+
41+
2) Build and run `trtorchrt_example`
42+
43+
`trtorchrt_example` is a binary which loads the torchscript modules `conv_gelu.jit` or `norm.jit` and runs the TRT engines on a random input using TRTorch runtime components. Checkout the `main.cpp` and `Makefile ` file for necessary code and compilation dependencies.
44+
45+
To build and run the app
46+
47+
```sh
48+
cd examples/trtorchrt_example
49+
make
50+
# If paths are different than the ones below, change as necessary
51+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/deps/trtorch/lib:$(pwd)/deps/libtorch/lib:$(pwd)/deps/tensorrt/lib:$(pwd)/deps/cudnn/lib64:/usr/local/cuda/lib
52+
./trtorchrt_example $PWD/examples/trtorchrt_example/norm.jit
53+
```

examples/trtorchrt_example/deps/.gitkeep

Whitespace-only changes.
File renamed without changes.

0 commit comments

Comments
 (0)