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

Why official torch2trt doesn't invoke any plugin, but this invoke too many plugins even with simple model #7

Open
lucasjinreal opened this issue Oct 10, 2020 · 4 comments

Comments

@lucasjinreal
Copy link

I tested mobilenetv2.

In official repo, it can generate without any plugin, this repo will have.

image
image

I doesn't need dynamic in simple model, what's the differences between offical repo?

@grimoire
Copy link
Owner

Hi
In these 'simple model' case, It is caused by adaptiveavgpool2d/adaptivemaxpool2d, Here is the difference

official onnx this
static o o o
dynamic-output_size=1 x o o
dynamic-output_size!=1 x x o
w/o plugin o o x

official implement it by pooling with the stride and kernel_size, it is easy, but can not work on dynamic case.

onnx use reduce ops to do the pooling, all value along given dims are gather together as one value. It is cool, but fails when output_size!=1

I create this repo because sometimes we need to do downsampling with adaptivepool such as bfp

                gathered = F.adaptive_max_pool2d(
                    inputs[i], output_size=gather_size)

TRT did not have adaptivepool and I can not find a 'plan B' which does not need plugins.

Most other plugins are created for similar reasons. Either TRT does not have an implementation or TRT can not do dynamic conversion.

You can replace the AdaptiveAvgPool2d in your model to AvgPool2d if you does not need dynamic shape support.

Or simply use official one, I have change the name of this project yesterday night, You can install both of then without conflict(I did not tested, if something is wrong, please let me know).

@lucasjinreal
Copy link
Author

@grimoire I will have a test

@likegogogo
Copy link

Hi
In these 'simple model' case, It is caused by adaptiveavgpool2d/adaptivemaxpool2d, Here is the difference

official onnx this
static o o o
dynamic-output_size=1 x o o
dynamic-output_size!=1 x x o
w/o plugin o o x
official implement it by pooling with the stride and kernel_size, it is easy, but can not work on dynamic case.

onnx use reduce ops to do the pooling, all value along given dims are gather together as one value. It is cool, but fails when output_size!=1

I create this repo because sometimes we need to do downsampling with adaptivepool such as bfp

                gathered = F.adaptive_max_pool2d(
                    inputs[i], output_size=gather_size)

TRT did not have adaptivepool and I can not find a 'plan B' which does not need plugins.

Most other plugins are created for similar reasons. Either TRT does not have an implementation or TRT can not do dynamic conversion.

You can replace the AdaptiveAvgPool2d in your model to AvgPool2d if you does not need dynamic shape support.

Or simply use official one, I have change the name of this project yesterday night, You can install both of then without conflict(I did not tested, if something is wrong, please let me know).

弱弱顺便问一下哈,what is w/o plugin?
@grimoire

@grimoire
Copy link
Owner

grimoire commented Sep 9, 2021

@ideafold without plugin

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants