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

Export dynamic batch size ONNX using ONNX's DeformConv #167

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

itskyf
Copy link

@itskyf itskyf commented Jan 20, 2025

This PR replaces the usage of deform_conv2d_onnx_exporter with the native DeformConv operator available in ONNX opset 19. The exported ONNX model now supports dynamic batch sizes.

Notes

@ZhengPeng7
Copy link
Owner

ZhengPeng7 commented Jan 20, 2025

Thanks a lot! I'll take time to look at it tomorrow, which really helps.
BTW, could you update the PR with no output and minimal modification in the notebook? That would be very nice for me to read and test the updated part in a clear way.

@itskyf
Copy link
Author

itskyf commented Jan 21, 2025

Sure, I've updated the notebook to reduce the modifications.

@alfausa1
Copy link

alfausa1 commented Jan 21, 2025

Thank you so much, @itskyf, for your contribution! Have you had a chance to test whether the execution works with ONNX Runtime?

@ZhengPeng7
Copy link
Owner

截屏2025-01-21 19 47 42 Hi, @itskyf. Did you successfully export the ONNX model? I tried it but met this problem. I tried both `PyTorch==2.0.1+onnxruntime-gpu==1.18.1` and `PyTorch==2.5.1+onnxruntime-gpu==1.20.1`).

@alfausa1
Copy link

Hi @ZhengPeng7,

I believe the issue arises because ONNX has implemented the DeformConv operator, but unfortunately, ONNX Runtime does not currently support it. As a result, any code that includes this operator cannot be executed within a Runtime Session. :/

@itskyf
Copy link
Author

itskyf commented Jan 21, 2025

@ZhengPeng7 ah, I forgot to mention that we need to also update the onnx package for opset 19.
@alfausa1 I faced the same problem. The dynamic batched model can only be used after TensorRT conversion. But since DefirmConv is an ONNX operator, I hope it will be supported in ONNXRuntime soon.

@alfausa1
Copy link

@itskyf Could you please provide the code in which you have converted the dynamic batched model to TensorRT? Thanks in advance!

@jhwei
Copy link

jhwei commented Jan 23, 2025

Thanks for @itskyf 's PR. This is exactly what I tested, and it worked.

I have a question about this PR for @itskyf

When I tested in this way, I found the result trt engine will work as expected when the batch size used when generating is different from batch size used for inferencing. And I figured out #166 this change should be made. Do you find the same issue ?

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