Hi, I want to use layers that are only implemented in ONNX opset version 20 and higher.
However, onnx.export() cannot be used because it supports up to opset version 17 only. I’m trying to use onnx.dynamo_export(), but it returns a warning saying, ‘torch.onnx.dynamo_export only implements opset version 18 for now. If you need to use a different opset version, please register them with register_custom_op.’
I don’t understand how to use register_custom_op. My model includes GELU; how can I ensure the GELU layer is exported correctly?
Unfortunately, using register_custom_op to export a model with GELU and a higher opset version than 18 is not currently supported in PyTorch.
Here are some alternative approaches you can consider:
Upgrade PyTorch:
Check if you’re using the latest stable version of Official Site PyTorch. Newer versions might have better support for higher opset versions and GELU export.
2. Use a custom function:
You can define a custom function that replicates the GELU behavior using existing ONNX operators supported by your desired opset version. This might involve using erf or other mathematical approximations.
3. Wait for future updates:
The PyTorch developers are actively working on extending dynamo_export to support higher opset versions and more operators like GELU. Keep an eye on future releases for potential improvements.
4. Consider alternative frameworks:
If exporting to ONNX with higher opset versions is crucial, you might need to explore other frameworks like TensorFlow or ONNX Runtime that offer better support for newer opset versions and potentially have native GELU implementations.
Additional notes:
While register_custom_op exists, it’s intended for advanced use cases and requires deep understanding of ONNX operators and their implementation details.
Using a custom function can be a more straightforward approach if you’re comfortable with defining and implementing the GELU behavior using existing ONNX operators.