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

InstanceNormalization plugin not working with dynamic input despite check removed (+ potential fix) #1222

Closed
awennersteen opened this issue Apr 29, 2021 · 2 comments
Labels
Plugins triaged Issue has been triaged by maintainers

Comments

@awennersteen
Copy link

Description

Commit da40554 mistakenly removes the check for dynamic shapes in instanceNormalization plugin.

This diff from tag 21.04 fixes it for me, but I'm not sure if it has any consequences:

diff --git a/plugin/instanceNormalizationPlugin/instanceNormalizationPlugin.cpp b/plugin/instanceNormalizationPlugin/instanceNormalizationPlugin.cpp
index f13a9de..e87017c 100644
--- a/plugin/instanceNormalizationPlugin/instanceNormalizationPlugin.cpp
+++ b/plugin/instanceNormalizationPlugin/instanceNormalizationPlugin.cpp
@@ -268,7 +268,7 @@ void InstanceNormalizationPlugin::detachFromContext()
 void InstanceNormalizationPlugin::configurePlugin(const nvinfer1::DynamicPluginTensorDesc* in, int nbInputs,
     const nvinfer1::DynamicPluginTensorDesc* out, int nbOutputs)
 {
-    auto input_dims = in[0].desc.dims;
+    auto input_dims = in[0].max;
     int n = input_dims.d[0];
     int c = input_dims.d[1];
     size_t nchan_bytes = c * sizeof(float);

Environment

TensorRT Version: 7.2.x

Steps to reproduce

Convert onnx model with trtexec

trtexec --onnx=model.onnx --saveEngine=model.engine --optShapes=data:4x3x64x64 --minShapes=data:1x3x64x64 --maxShapes=data:8x3x64x64

Yields

/TensorRT/plugin/instanceNormalizationPlugin/instanceNormalizationPlugin.cpp (281) - Cuda Error in configurePlugin: 2 (out of memory)
terminate called after throwing an instance of 'nvinfer1::plugin::CudaError'
  what():  std::exception
Aborted (core dumped)

But explicit batch works (since we're not trying to cudamalloc negative memory)

@ttyio
Copy link
Collaborator

ttyio commented Apr 29, 2021

@awennersteen ,
yes this fix is correct, I also mention this in #1183 (comment)

we will fix this in the next integration from internal to github, thanks!

@ttyio ttyio added Plugins triaged Issue has been triaged by maintainers labels Apr 29, 2021
@ttyio
Copy link
Collaborator

ttyio commented Jun 7, 2021

closing since no activity for more than 3 weeks, please reopen if you still have question, thanks

@ttyio ttyio closed this as completed Jun 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Plugins triaged Issue has been triaged by maintainers
Projects
None yet
Development

No branches or pull requests

2 participants