Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE][Reproducing issue] : View converter , bs >1 #585

Draft
wants to merge 436 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
436 commits
Select commit Hold shift + click to select a range
295961a
Merge pull request #56 from NVIDIA-AI-IOT/pyt1.2
jaybdub Sep 10, 2019
e394a14
consider ceil_mode of torch.nn.MaxPool2d
mt1871 Sep 13, 2019
59e0ec8
registered add for more interfaces
jaybdub Sep 17, 2019
5ad17bc
added additional div interfaces
jaybdub Sep 17, 2019
e951955
added additional mul interfaces
jaybdub Sep 17, 2019
51e0c95
Merge pull request #61 from NVIDIA-AI-IOT/torch_methods
jaybdub Sep 17, 2019
5c41345
added clamp, clamp_min, clamp_max
jaybdub Sep 17, 2019
08fecd3
added clamp tensor
jaybdub Sep 17, 2019
2769c29
added normalize
jaybdub Sep 18, 2019
493515c
Merge pull request #62 from NVIDIA-AI-IOT/normalize
jaybdub Sep 18, 2019
43d1b1a
added test cases for MaxPool2d
mt1871 Sep 18, 2019
d2825e5
Merge pull request #57 from mt1871/fix_maxpool_ceilmode
jaybdub Sep 19, 2019
630194c
added mobilenet_v2 to module tests
jaybdub Sep 25, 2019
81e73d2
Merge pull request #70 from NVIDIA-AI-IOT/mobilenet_v2
jaybdub Sep 25, 2019
f29ff96
added parsed_args
jaybdub Sep 27, 2019
d409f13
added utilities to support normalize
jaybdub Sep 27, 2019
dc547b8
dtype to normalized constants
jaybdub Sep 27, 2019
c429ae7
added avg_pool2d and removed AvgPool2d
jaybdub Sep 27, 2019
5abcbbe
fixed normalize
jaybdub Sep 27, 2019
d47af74
added missing avg_pool2d.py
jaybdub Sep 27, 2019
916e25d
added max_pool2d removed MaxPool2d
jaybdub Sep 27, 2019
100bcdb
fixed arg parsing in avg_pool2d and max_pool2d
jaybdub Sep 27, 2019
46534bd
refactor
jaybdub Sep 29, 2019
83f1765
Merge pull request #73 from NVIDIA-AI-IOT/functional_refactor
jaybdub Sep 29, 2019
05e7022
added split and chunk
jaybdub Sep 30, 2019
d6a3fd5
added shufflenet to module tests
jaybdub Sep 30, 2019
9b616d7
Merge pull request #74 from NVIDIA-AI-IOT/split
jaybdub Sep 30, 2019
a838a19
added permute
jaybdub Sep 30, 2019
7b46e02
fixed permute converter name
jaybdub Sep 30, 2019
c0c89d2
Merge pull request #75 from NVIDIA-AI-IOT/permute
jaybdub Sep 30, 2019
72f0cd7
added trt_ method to get/create/broadcast tensors
jaybdub Oct 1, 2019
0bfe27d
modified normalize to use trt_
jaybdub Oct 1, 2019
5699dcd
fixed trt_ to handle single tenosr outputs
jaybdub Oct 1, 2019
4c21936
updated converters to use trt_ instead of input._trt
jaybdub Oct 1, 2019
9745e31
added __radd__ to support left hand primitives
jaybdub Oct 1, 2019
9bcadbb
added rdiv and radd
jaybdub Oct 1, 2019
3d2fef8
added rdiv, rmul, radd
jaybdub Oct 1, 2019
e69c577
replcaed input._trt with trt_ in interpolate
jaybdub Oct 1, 2019
fec6b22
Merge pull request #80 from NVIDIA-AI-IOT/prepare_broadcastable_tensors
jaybdub Oct 1, 2019
f27aa27
added mnasnet to test
jaybdub Oct 1, 2019
922a0f7
Merge pull request #81 from NVIDIA-AI-IOT/prepare_broadcastable_tensors
jaybdub Oct 1, 2019
f29e1c9
refactored tests
jaybdub Oct 2, 2019
5b1d552
refactored tests
jaybdub Oct 2, 2019
a660786
Merge branch 'extra_tests' of https://github.com/NVIDIA-AI-IOT/torch2…
jaybdub Oct 2, 2019
4852b82
fix missing --include argument in test.py
jaybdub Oct 2, 2019
f6eae5a
Merge pull request #84 from NVIDIA-AI-IOT/extra_tests
jaybdub Oct 2, 2019
7693e81
removed copy(..) from conversion hook
jaybdub Oct 2, 2019
f2c931e
removed copy(..) from conversion hook
jaybdub Oct 2, 2019
bbe7b1d
Merge branch 'py2_fix' of https://github.com/NVIDIA-AI-IOT/torch2trt …
jaybdub Oct 2, 2019
506fb87
handle __div__, __rdiv__ and __idiv__ to support Python2
jaybdub Oct 2, 2019
beccc1a
Merge pull request #11 from narendasan/narendasan/gitignore
jaybdub Oct 2, 2019
c7cb4bd
Merge pull request #10 from narendasan/narendasan/typo_in_readme
jaybdub Oct 2, 2019
c982944
Merge pull request #85 from NVIDIA-AI-IOT/py2_fix
jaybdub Oct 2, 2019
887ca21
Merge branch 'master' into narendasan/custom_dep_locations
jaybdub Oct 2, 2019
6fafa46
removes caffe2 from build
jaybdub Oct 2, 2019
950109b
Merge pull request #12 from narendasan/narendasan/custom_dep_locations
jaybdub Oct 2, 2019
c8b3619
added support for prelu
jaybdub Oct 4, 2019
b962b4d
Merge pull request #88 from NVIDIA-AI-IOT/prelu
jaybdub Oct 4, 2019
9bbf348
added supported unary ops
jaybdub Oct 4, 2019
972a7c7
Merge pull request #89 from NVIDIA-AI-IOT/unary_supported
jaybdub Oct 4, 2019
1c87da6
added max reduce/elementwise
jaybdub Oct 4, 2019
86feae5
added min reduce/elementwise
jaybdub Oct 4, 2019
dfc7483
added sub
jaybdub Oct 4, 2019
601b94e
added pow elementwise
jaybdub Oct 4, 2019
7947855
fixed min/max reduce all
jaybdub Oct 4, 2019
0a3eaee
added prod
jaybdub Oct 4, 2019
16ac488
added sum reduce
jaybdub Oct 4, 2019
95a5849
increment patch
jaybdub Oct 4, 2019
8d00907
separate tensors for test/convert to ensure falsely added constants c…
jaybdub Oct 4, 2019
a6ee9c4
more relu interfaces
jaybdub Oct 4, 2019
28e1700
Merge pull request #90 from NVIDIA-AI-IOT/supported_elementwise
jaybdub Oct 4, 2019
599524b
fixed broadcast shapes, removed final_shapes
jaybdub Oct 4, 2019
f25eaa5
removed all-dim test from max/min, since this cannot be supported by …
jaybdub Oct 4, 2019
59ee834
removed leaf check
jaybdub Oct 4, 2019
d8b43bd
added jetson xavier benchmark
jaybdub Oct 4, 2019
d7d967c
Merge pull request #91 from NVIDIA-AI-IOT/broadcast_fix
jaybdub Oct 4, 2019
9e8753a
added python2 serialization fix (bytes -> bytearray)
jaybdub Oct 4, 2019
713086d
added save_load test
jaybdub Oct 4, 2019
2d373fe
added save/load test
jaybdub Oct 4, 2019
06ccc64
Merge pull request #93 from NVIDIA-AI-IOT/py2_serialization_fix
jaybdub Oct 4, 2019
4b5a3c2
extra ignore
jaybdub Oct 4, 2019
82e694c
Merge pull request #94 from NVIDIA-AI-IOT/ignore
jaybdub Oct 4, 2019
6c403fc
added leaky_relu
jaybdub Oct 4, 2019
11c465c
added elu
jaybdub Oct 4, 2019
e2ebb8e
added selu, softsign, elu
jaybdub Oct 5, 2019
9b3a3c4
added softplus
jaybdub Oct 5, 2019
2cb97a3
softplus, softsign
jaybdub Oct 5, 2019
4046625
Merge pull request #95 from NVIDIA-AI-IOT/activations_supported
jaybdub Oct 5, 2019
384384e
added network->dot graph util method
jaybdub Oct 8, 2019
e0b0e71
added network->dot graph util method
jaybdub Oct 8, 2019
345b561
merged
jaybdub Oct 8, 2019
323f1d3
graphviz module prefix fix
jaybdub Oct 8, 2019
e83730e
fixed Linear w.o bias
jaybdub Oct 20, 2019
7255a24
Merge pull request #125 from jaybdub/linear_no_bias
jaybdub Oct 20, 2019
3fac66b
handle non-existance torch method with existing converter
jaybdub Oct 21, 2019
c76f141
added profiling
jaybdub Oct 21, 2019
ace0abd
added network->dot graph util method
jaybdub Oct 8, 2019
f7dbb96
added network->dot graph util method
jaybdub Oct 8, 2019
84101a9
graphviz module prefix fix
jaybdub Oct 8, 2019
97260f2
handle non-existance torch method with existing converter
jaybdub Oct 21, 2019
0a2c3eb
added profiling
jaybdub Oct 21, 2019
dc620d9
Merge branch 'network_visualization' of https://github.com/NVIDIA-AI-…
jaybdub Oct 21, 2019
7984972
Merge pull request #106 from NVIDIA-AI-IOT/network_visualization
jaybdub Oct 21, 2019
e520dd2
added dummy
jaybdub Oct 28, 2019
5ab1561
pass for Tensor.dim Tensor.size dummy converters
jaybdub Oct 28, 2019
b967c99
incremented patch
jaybdub Oct 28, 2019
53ce056
Merge pull request #138 from NVIDIA-AI-IOT/unsupported_methods
jaybdub Oct 28, 2019
a32e684
fixed upsampling<->interpolate translation
Nov 19, 2019
af56018
reverted changes to fix build
Nov 19, 2019
4da14ed
renamed test nn_scale->upsample_scale_factor2
jaybdub Nov 23, 2019
33af10d
Merge branch 'SrivastavaKshitij-kshitij/upsample_plugin_fix'
jaybdub Nov 23, 2019
112922b
added int8 support
jaybdub Nov 26, 2019
46bb0df
minor refactor/comment fix of DatasetCalibrator
jaybdub Nov 26, 2019
a7c35d5
handle loose dataset types
jaybdub Nov 26, 2019
8e6e475
fixed int8 support for TensorRT 5.0
jaybdub Nov 27, 2019
b8a54ac
fix int8_support python2
jaybdub Nov 27, 2019
f60509b
refactor int8 buffer assignment using zip()
jaybdub Dec 3, 2019
3a05d4a
increment vers
jaybdub Dec 3, 2019
eb54b5f
Merge pull request #168 from NVIDIA-AI-IOT/int8_support
jaybdub Dec 3, 2019
23ac868
added instance norm from track_stats=True
jaybdub Dec 12, 2019
5f30709
instance norm
jaybdub Dec 13, 2019
67ab729
optimize instance norm by merging sqrt inside scale layer
jaybdub Dec 13, 2019
b3e0c08
Merge pull request #193 from NVIDIA-AI-IOT/instance_norm
jaybdub Dec 13, 2019
c374807
added converter / tests for torch.Tensor.__getitem__
jaybdub Dec 14, 2019
1ee2c05
Merge pull request #195 from NVIDIA-AI-IOT/getitem
jaybdub Dec 14, 2019
1a26b54
fixed Linear for N, *, H case
jaybdub Dec 14, 2019
190a84d
Merge pull request #196 from NVIDIA-AI-IOT/linear_fix
jaybdub Dec 14, 2019
8142c6f
fixed permute for list args
jaybdub Dec 17, 2019
07831d6
Merge pull request #206 from NVIDIA-AI-IOT/permute_listarg_fix
jaybdub Dec 17, 2019
72f6ec2
added support for adaptive_max_pool2d using regular pooling
jaybdub Dec 17, 2019
d526b24
Merge pull request #207 from NVIDIA-AI-IOT/adaptive_max_pool2d
jaybdub Dec 17, 2019
c6d047f
update clamp
SnowMasaya Jan 6, 2020
1756aa9
rm idea
SnowMasaya Jan 6, 2020
e22844a
Merge pull request #224 from SnowMasaya/clamp
jaybdub Jan 7, 2020
6be6da4
plugin setup.py
jaybdub Apr 10, 2020
1142079
asdf
jaybdub Apr 28, 2020
b5bb91d
interpolate torch serialization
jaybdub Apr 28, 2020
62a8918
version handling
jaybdub Apr 29, 2020
1ca350b
fix padding issue of 2d transposed conv.
FrogKuma May 20, 2020
fb72cac
added upsample code in converters
Nov 14, 2019
f6a7eaf
added functional <--> nn.module binding for upsample
Nov 15, 2019
3ecd4f5
made changes:
Nov 15, 2019
3c00f09
working upsample with trt6
Nov 15, 2019
558cbff
added F.interpolate converter
Nov 15, 2019
f48ad4b
(WIP), trt version check
Nov 18, 2019
8f63b22
Add 3d convolutions and interpolations
oliver-batchelor Jan 30, 2020
3ebf1b9
Update lots of ops
oliver-batchelor Feb 2, 2020
63e65d4
More opreations
oliver-batchelor Feb 2, 2020
a4f0b52
Remove tools import
oliver-batchelor Feb 16, 2020
393a13d
fixed trt version compatibility for torch2trt.py
May 25, 2020
401be2e
separated trt 7 ops
May 25, 2020
8cb3606
added original ops
May 25, 2020
3ce1371
reverting to default for trt 7
May 25, 2020
af2674c
changed value from 7 to 7.0
May 26, 2020
3c16ea5
added unit test for ConvTranspose2d and fixed an indentation error in…
Jun 4, 2020
512a511
added testcase for commonly used kernel size 4, stride 2, padding 1 c…
jaybdub Jun 4, 2020
a1daf58
Merge branch 'SrivastavaKshitij-transpose_conv2d'
jaybdub Jun 4, 2020
f3881cc
Merge branch 'master' into new_trt_ops
SrivastavaKshitij Jun 4, 2020
b2c8c13
added enabled kwarg to register_converter and add_module_test
jaybdub Jun 9, 2020
5c31892
moved trt7 ops to converters dir
jaybdub Jun 9, 2020
e3f45d3
merged interpolate modules
jaybdub Jun 9, 2020
1f4f69c
format init
jaybdub Jun 9, 2020
229f807
increment minor vers
jaybdub Jun 9, 2020
57c8188
added --plugins to setup
jaybdub Jun 10, 2020
a22e82c
plugins disclaimer to readme
jaybdub Jun 10, 2020
1a5a397
disable interpolate if PyTorch < 1.3
jaybdub Jun 10, 2020
b31611c
fixed interpolate plugin checking
jaybdub Jun 10, 2020
1f66266
Merge pull request #332 from NVIDIA-AI-IOT/SrivastavaKshitij-new_trt_ops
jaybdub Jun 10, 2020
75fd8e2
allowed plugin loading to silent fail
jaybdub Jun 11, 2020
bea0f6a
Merge pull request #337 from NVIDIA-AI-IOT/plugin_silentfail
jaybdub Jun 11, 2020
22e1118
added ONNX conversion alternative to torch2trt
jaybdub Jun 11, 2020
fe76a7b
Merge pull request #338 from NVIDIA-AI-IOT/onnx_alternative
jaybdub Jun 11, 2020
b0a7724
Add requirements.txt
vellamike Jul 2, 2020
2aa01dd
Added install information
vellamike Jul 2, 2020
ed37a06
Update README.md
vellamike Jul 6, 2020
f7ff467
readme tensorrt install tip
jaybdub Jul 8, 2020
d88fcd5
Merge pull request #361 from NVIDIA-AI-IOT/vellamike-update-requirements
jaybdub Jul 8, 2020
f9828cc
added preliminary code for narrow
Aug 25, 2020
5c4ad8f
narrow converter added successfully
Aug 28, 2020
f3fe46c
softmax neg dim
jaybdub Aug 31, 2020
1f1701d
Merge pull request #396 from NVIDIA-AI-IOT/softmax_negdim_fix
jaybdub Aug 31, 2020
63895f0
Merge pull request #393 from SrivastavaKshitij/narrow_converter
jaybdub Aug 31, 2020
d245496
added add_missing_trt_tensors and broadcast_trt_tensors
jaybdub Sep 1, 2020
fb8da9a
bugfix and add
jaybdub Sep 1, 2020
d6e6f3b
add tests
jaybdub Sep 1, 2020
d14c6b7
div
jaybdub Sep 1, 2020
a08e6dc
dimfix
jaybdub Sep 1, 2020
742b3fd
dump converters script
jaybdub Sep 2, 2020
765c3ad
docs
jaybdub Sep 2, 2020
3adbbe1
changelog contributing
jaybdub Sep 2, 2020
3beeae2
docs
jaybdub Sep 2, 2020
422e1e6
typos
jaybdub Sep 2, 2020
4933faf
docs
jaybdub Sep 2, 2020
3ddd70d
expose the batch size of INT8 calibration as parameter, since different
Chujingjun Sep 2, 2020
48eb79e
Merge pull request #397 from NVIDIA-AI-IOT/const_dim_fix
jaybdub Sep 2, 2020
f5fb752
Merge pull request #398 from Chujingjun/master
jaybdub Sep 2, 2020
16492db
dump converters script
jaybdub Sep 2, 2020
88416f9
docs
jaybdub Sep 2, 2020
1a59749
changelog contributing
jaybdub Sep 2, 2020
93abd9f
docs
jaybdub Sep 2, 2020
384ac89
typos
jaybdub Sep 2, 2020
656805b
docs
jaybdub Sep 2, 2020
571cb00
docs
jaybdub Sep 2, 2020
a263fe0
docs build contrib
jaybdub Sep 2, 2020
0655a80
build docs
jaybdub Sep 2, 2020
1474eee
asdf
jaybdub Sep 2, 2020
3d496ae
docs merge
jaybdub Sep 2, 2020
88d8038
merge fixes
jaybdub Sep 2, 2020
5160901
asdf
jaybdub Sep 3, 2020
5aae576
mkdocs
jaybdub Sep 3, 2020
86d9c3a
docs
jaybdub Sep 3, 2020
67de214
contrib plain md
jaybdub Sep 3, 2020
6c0aec7
basic usage
jaybdub Sep 3, 2020
bd2cd11
issues pathfix
jaybdub Sep 3, 2020
50169ef
broken link
jaybdub Sep 3, 2020
62afaf1
release build docs
jaybdub Sep 3, 2020
c9dcd5e
Merge pull request #399 from jaybdub/docs
jaybdub Sep 3, 2020
3efb89d
Reduce precision docs (#400)
jaybdub Sep 3, 2020
4141730
Update reduced_precision.md (#402)
jaybdub Sep 3, 2020
7563770
Update mkdocs.yml
jaybdub Sep 3, 2020
ea835dc
remove ndim referneces to support older pytorch versions (#415)
jaybdub Sep 15, 2020
b0cc8e7
Assert that inputs are contiguous (#418)
alsrgv Sep 18, 2020
a9a6a53
Add layer names (#432)
jaybdub Oct 19, 2020
d1fa6f9
Sandeepkumar skb groupnorm plugin (#437)
jaybdub Nov 4, 2020
adccbf1
Koenvandesande remove duplicate filenames (#448)
jaybdub Nov 17, 2020
81024cc
allow direct method setting to support custom layers (#460)
jaybdub Dec 2, 2020
2b1827e
custom converter to changelog (#462)
jaybdub Dec 2, 2020
033df0c
added expand converter (#487)
jaybdub Jan 13, 2021
3e4ed64
Additional converters for floordiv, mod, ne, and torch::tensor() oper…
meremeev Feb 22, 2021
a5bdd29
added passing of torch2trt_kwargs to conversion context (#482)
jaybdub Feb 25, 2021
e55a7a5
added filter to floordiv to only enable for pytorch 1.6+ (#511)
jaybdub Feb 25, 2021
15da623
increment version to 0.2.0 (#517)
jaybdub Mar 2, 2021
44977a9
Release push docs tagfix (#519)
jaybdub Mar 2, 2021
8100c6a
Update README.md
jaybdub Mar 20, 2021
72c81f9
Create CLA.md
jaybdub Mar 20, 2021
b9d9e73
Functional conv (#535)
jaybdub Mar 25, 2021
8f7f4f7
added contributors page
jaybdub Apr 26, 2021
2d6150a
Added John Welsh to CONTRIBUTORS.md
jaybdub Apr 26, 2021
1dc9ad1
I have read and agree to the Contributor License Agreement as written…
jaybdub Apr 26, 2021
e01279c
Merge pull request #550 from jaybdub/contributors
jaybdub Apr 26, 2021
2653a71
added silu converter
Jun 15, 2021
fb67b42
functional linear converter
Jun 15, 2021
5ee6033
added gelu converter
Jun 15, 2021
ddb3558
added layer_norm converter
Jun 15, 2021
9457b8c
Merge pull request #570 from jaybdub/linear_functional_converter
jaybdub Jun 15, 2021
b604881
added converter for torch.roll
Jun 16, 2021
0963e49
Merge pull request #574 from jaybdub/roll_converter
jaybdub Jun 16, 2021
cabb04f
fixed merged conflict
Jul 2, 2021
1a7e216
recreating issue with view converter , bs >1
Jul 6, 2021
ac95df3
added some print statements for debugging
Jul 7, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions CLA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
## Individual Contributor License Agreement (CLA)

**Thank you for submitting your contributions to this project.**

By signing this CLA, you agree that the following terms apply to all of your past, present and future contributions
to the project.

### License.

You hereby represent that all present, past and future contributions are governed by the
[MIT License](https://opensource.org/licenses/MIT)
copyright statement.

This entails that to the extent possible under law, you transfer all copyright and related or neighboring rights
of the code or documents you contribute to the project itself or its maintainers.
Furthermore you also represent that you have the authority to perform the above waiver
with respect to the entirety of you contributions.

### Moral Rights.

To the fullest extent permitted under applicable law, you hereby waive, and agree not to
assert, all of your “moral rights” in or relating to your contributions for the benefit of the project.

### Third Party Content.

If your Contribution includes or is based on any source code, object code, bug fixes, configuration changes, tools,
specifications, documentation, data, materials, feedback, information or other works of authorship that were not
authored by you (“Third Party Content”) or if you are aware of any third party intellectual property or proprietary
rights associated with your Contribution (“Third Party Rights”),
then you agree to include with the submission of your Contribution full details respecting such Third Party
Content and Third Party Rights, including, without limitation, identification of which aspects of your
Contribution contain Third Party Content or are associated with Third Party Rights, the owner/author of the
Third Party Content and Third Party Rights, where you obtained the Third Party Content, and any applicable
third party license terms or restrictions respecting the Third Party Content and Third Party Rights. For greater
certainty, the foregoing obligations respecting the identification of Third Party Content and Third Party Rights
do not apply to any portion of a Project that is incorporated into your Contribution to that same Project.

### Representations.

You represent that, other than the Third Party Content and Third Party Rights identified by
you in accordance with this Agreement, you are the sole author of your Contributions and are legally entitled
to grant the foregoing licenses and waivers in respect of your Contributions. If your Contributions were
created in the course of your employment with your past or present employer(s), you represent that such
employer(s) has authorized you to make your Contributions on behalf of such employer(s) or such employer
(s) has waived all of their right, title or interest in or to your Contributions.

### Disclaimer.

To the fullest extent permitted under applicable law, your Contributions are provided on an "as is"
basis, without any warranties or conditions, express or implied, including, without limitation, any implied
warranties or conditions of non-infringement, merchantability or fitness for a particular purpose. You are not
required to provide support for your Contributions, except to the extent you desire to provide support.

### No Obligation.

You acknowledge that the maintainers of this project are under no obligation to use or incorporate your contributions
into the project. The decision to use or incorporate your contributions into the project will be made at the
sole discretion of the maintainers or their authorized delegates.
3 changes: 2 additions & 1 deletion CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Below is a list of developers who have contributed to torch2trt. This is also used to track contributors
who have agreed to torch2trt's Contributor License Agreement.

- [John Welsh](https://github.com/jaybdub) (CLA)
- John Welsh

## Becoming a Contributor
Expand Down Expand Up @@ -42,6 +43,6 @@ In some instances, you may be requested to sign torch2trt's Contributor License
4. Make a signed commit with the following text

```md
git commit -S -m "I have read and agree to the Contributor License Agreement as written in the file CLA.pdf of this project. Signed, <Full Name>"
git commit -S -m "I have read and agree to the Contributor License Agreement as written in the file CLA.md of this project. Signed, <Full Name>"
```

14 changes: 9 additions & 5 deletions torch2trt/converters/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
@tensorrt_converter('torch.unsqueeze')
def convert_view(ctx):
input = ctx.method_args[0]
print("input_shape",input.shape)
input_trt = add_missing_trt_tensors(ctx.network, [input])[0]
print("input_trt",input_trt.shape)
output = ctx.method_return
print("o/p",output.shape)
layer = ctx.network.add_shuffle(input_trt)
layer.reshape_dims = tuple(output.shape[1:])
print("trt layer o/p shape",layer.get_output(0).shape)
output._trt = layer.get_output(0)


Expand Down Expand Up @@ -45,13 +49,13 @@ def forward(self, x):
return x.unsqueeze(dim=self.dim)


@add_module_test(torch.float32, torch.device('cuda'), [(1, 3)])
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 3)])
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 3, 3)])
#@add_module_test(torch.float32, torch.device('cuda'), [(1, 3)])
#@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 3)])
@add_module_test(torch.float32, torch.device('cuda'), [(2, 3, 3, 3)],max_batch_size=3)
def test_view_1d():
return View(1, -1)
Copy link
Contributor

@jaybdub jaybdub Jul 9, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like the test case is hard-fixing the batch dimension to 1 here.

In general, TensorRT engines are broadcast across the batch dimension, so operations that change the batch dimension aren't permitted.

Perhaps adding a test case with View(2, ...) would work for batch size 2. Or maybe even View(-1, ...) with other dimensions specified explicitly.



'''
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3)])
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 3)])
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 3, 3)])
Expand All @@ -73,5 +77,5 @@ def test_unsqueeze():
@add_module_test(torch.float32, torch.device('cuda'), [(1, 3, 1, 3)])
def test_squeeze():
return Squeeze(2)

'''

4 changes: 3 additions & 1 deletion torch2trt/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def run(self):
if outputs[i].dtype == torch.bool:
max_error_i = torch.sum(outputs[i] ^ outputs_trt[i])
else:
print("under test.py")
print("pytorch op",outputs[i].size(),"trt op",outputs_trt[i].size())
max_error_i = torch.max(torch.abs(outputs[i] - outputs_trt[i]))

if max_error_i > max_error:
Expand Down Expand Up @@ -144,4 +146,4 @@ def run(self):
print('NUM_TESTS: %d' % num_tests)
print('NUM_SUCCESSFUL_CONVERSION: %d' % num_success)
print('NUM_FAILED_CONVERSION: %d' % num_error)
print('NUM_ABOVE_TOLERANCE: %d' % num_tolerance)
print('NUM_ABOVE_TOLERANCE: %d' % num_tolerance)
13 changes: 8 additions & 5 deletions torch2trt/torch2trt.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,18 @@ def add_missing_trt_tensors(network, tensors):
# get tensor w/ _trt
# or... add constant for scalar primitive
if isinstance(t, float) or isinstance(t, int):
print("if")
shape = (1,)
scalar = t * torch.ones(shape, dtype=dtype).cpu().numpy()
trt_tensor = network.add_constant(shape, scalar).get_output(0)
elif hasattr(t, "_trt"):
print("elif")
print(t.shape,t._trt.shape)
trt_tensor = t._trt

# or... add constant for leaf tensor w/o _trt
else:

print("else condition")
# remove all preceding ones, these can be re-inserted later when broadcasting
num_preceding_ones = 0
for j in range(len(t.shape)):
Expand All @@ -163,14 +166,13 @@ def add_missing_trt_tensors(network, tensors):
else:
break
shape = tuple(t.shape[num_preceding_ones:])

weight = t.detach().cpu().numpy()
t._trt = network.add_constant(shape, weight).get_output(0)
trt_tensor = t._trt


assert trt_tensor is not None

print(trt_tensor.shape)
trt_tensors[i] = trt_tensor

return trt_tensors
Expand Down Expand Up @@ -514,8 +516,9 @@ def torch2trt(module,
inputs_in = inputs

# copy inputs to avoid modifications to source data
inputs = [tensor.clone()[0:1] for tensor in inputs] # only run single entry

inputs = [tensor.clone() for tensor in inputs] # only run single entry
for tensor in inputs:
print(tensor.shape)
logger = trt.Logger(log_level)
builder = trt.Builder(logger)

Expand Down