-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Patch clip model for ONNX compatibility #219
Patch clip model for ONNX compatibility #219
Conversation
Changes to use INT32 for tokenization, since ONNX doesn't yet support ArgMax(INT64) Use explicit dimension for norm
Regarding the test error, I see that torch 1.7.1 requires indices to be LongTensor, whereas 1.8 and above allows both LongTensor and IntTensor. Do you have suggestions as to how we should workaround? I wonder how long 1.7.1 is going to be supported by CLIP. |
So I've pushed the change to preserve the behavior when torch version is < 1.8.0. This makes all the tests to pass again in 1.7.1, but 1.7.1 users won't benefit from this fix. |
For ONNX support, please use https://github.com/jina-ai/clip-as-service/ |
Respectfully, I don't think it's appropriate to promote your service in this PR. |
Thanks for the PR! I think branching based on torch version makes sense. |
How can you use |
Team,
When productionizing AI models like CLIP, it is often useful to be able to export to ONNX so that we can utilize training and serving ecosystem built around ONNX runtime. This PR includes changes that are necessary to make ONNX compilation and runtime working without needing to further patch the code:
With these changes, we can now compile and run ONNX models. For example:
I've locally verified the result. I see that CLIP has a github action to run pytest. I will be happy to further contribute by adding onnx-specific tests to see if the model can be compiled and the resulting model is correct.
I understand that ONNX compatibility might not be the primary goal of
CLIP
repo, but maintaining compatibility with ONNX will be immensely useful to the ML practitioners out in the wild, so please take a look at the change.Thanks!