Error ONNX Export failed, Hardtanh not supported
See original GitHub issueI tried to export a PyTorch model to ONNX and got this warning and error :
UserWarning: ONNX export failed on ATen operator hardtanh because torch.onnx.symbolic.hardtanh does not exist
RuntimeError: ONNX export failed: Couldn't export operator aten::hardtanh
So after some researches, I understood that PyTorch can’t export the operator Hardtanh. I tried to follow the tutorial to add export support but it seems like Hardtanh is not a standardized operator in ONNX. For this case, the tutorial says I have to add it to ONNX. How can I do that ? Is it possible to achieve this or should I wait for this operator to be supported or find another way to convert my model ?
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (7 by maintainers)
Top Results From Across the Web
NonImplementedError on using torch.onnx.export
The neural network has 2 inputs, one hidden layer with 5 neurons and a scalar output. Here's the code I'm working with: import...
Read more >ONNX export failed on unsafe_chunk - PyTorch Forums
I was trying to export the Tacotron2 model provided by torchaudio: import torch import torchaudio import onnx bundle = torchaudio.pipelines.
Read more >torch.onnx — PyTorch master documentation
from torch.autograd import Variable import torch.onnx import torchvision ... The export fails because PyTorch does not support exporting elu operator.
Read more >Python API: torch/onnx/symbolic.py Source File - Caffe2
78 raise RuntimeError("ONNX symbolic expected a constant value in the ... export failed on " + op + " because " + msg...
Read more >torch.onnx — PyTorch master documentation
Example: End-to-end AlexNet from PyTorch to ONNX. Tracing vs Scripting ... The export fails because PyTorch does not support exporting elu operator.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

You can propose to introduce HardTanh to ONNX, I think it’s common enough to be introduced.
https://github.com/pytorch/pytorch/pull/8804. However, Hardtanh can also be equivalently expressed by Clip.