ONNX权重类型转换 INT64 to INT32
使用TensorRT转换ONNX模型时,提示模型包含INT64变量,其不影响模型转换。如果想消除该提示,可以将INT64变量转为INT32即可。转换可使用:aadhithya/onnx-typecast: Script to typecast ONNX model parameters from INT64 to INT32. (github.com)
onnx-typecast
A simple python script to typecast ONNX model parameters from INT64 to INT32.
Why?
I wanted to play around with ONNX.js and soon figured out that it doesn't support onnx models with INT64 parameters. Also, OpenCV doesn't seem to support INT64 parameters.
What does this script do?
- The script goes through the parameters of each node of the onnx model and blindly converts INT64 parameters to INT32.
- It also converts the constant parameters from INT64 to INT32.
- Finally, creates a new model and saves it.
What's the catch?
- The script does not handle overflows and blindly converts all INT64 parameters to INT32.
- So ops that require
>INT32.maxorvalues may not perform as expected. - Please feel free to modify the script to account for this.
Alright. How do I use it?
- simple.
- Install requirements:
pip install -r requirements.txt - run:
python convert.py path/to/int64_model.onnx path/to/converted_int32_model.onnx
Also Checkout
- microsoft/onnxjs#168 (comment)
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!
