-
Notifications
You must be signed in to change notification settings - Fork 681
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
Torch VS TRT layer-wise debug ? #310
Comments
In my case, the results are much more worse. I also struggled a lot to convert and run trt model successfully. I am also looking the same solution. |
Hi All, Thanks for reaching out! Are you able to share the PyTorch model you're attempting to convert? Best, |
yes I converted the officially released model from https://github.com/dedoogong/SuperGluePretrainedNetwork You can just clone the repo and run(weight files and demo images are all included in the repo). I intentionally added all intermediate layer's outputs to return variables for TRT to recognize those as outputs so that it will not fuse the layers. you can see the TRT related codes : superglue.py and matching.py When I compared the results between TRT and torch model in the first conversion step(before saving the converted model), the two results were totally same. But after loading the converted model and run it again with different inputs, the two inference results start to be different! And only when I added all intermediate outputs to the models final output, the results are much better. So, I guess the layer fusion would cause the accuracy drop. |
I hope to find a easier way to manually handle some layer not to be fused as an optional torch2trt argument ( such as each layer's unique id or name) |
Hi dedoogong, Issue 1 - Incorrect results after loading modelCould you share the following information
Also, does your model use an interpolation / upsampling layer? I've refactored the serialization of the interpolate plugin in this branch if you want to give it a try. The refactoring is intended to resolve a different issue but would be worth checking. Issue 2 - Handling layer not to be fusedDo you mind sharing a small example of what you mean by a layer "not to be fused"? Do you mean to skip adding the layer (an identity operation)? |
Hello! Issue 1 - Incorrect results after loading model
Issue 2 - Handling layer not to be fusedsmall example: original model
"not to be fused" version (for being marked as outputs by TRT)
If you want any more request, please let me know! |
@dedoogong and @ma-siddiqui have you been able to solve the issue? |
I am trying to convert the SuperGlue model [https://github.com/dedoogong/SuperGluePretrainedNetwork] to Tensor-RT for subsequent execution of the same of TX2. Still struggling and haven't been able to get a breakthrough. Seems you had some success back in 2020. Can you kindly share your converted model? If not would it be possible to share scripts that you used for conversion? Regards |
Hello!
After a tons of trial and errors,
I finally struggled to have converted my model to TRT and run it successfully.
Even it was just a FP 32 normal conversion, the speed increased 3~4 times!
But the result accuracy was little bit worse than my expectation.
I guess there the causes would come from layer fusion.
I would like to debug layer by layer, but for example some part of my layers are packed into a nn.Sequential().
networ.mark_output("each layers output tensor") would be the workaround, but I think I can't apply this method when I use nn.Sequential() because I can't get the each inner layers(e.g., Conv , Bn, Relu..) output as it is processed implicitly.
Would you please kindly give me any hint to debug all layers between torch vs TRT?
Thank you!
The text was updated successfully, but these errors were encountered: