onnx2torch icon indicating copy to clipboard operation
onnx2torch copied to clipboard

Dynamic min/max values in Clip operation not supported

Open gary920209 opened this issue 1 year ago • 2 comments
trafficstars

Bug Description

I encountered an issue while converting CosyVoice speech tokenizer ONNX model to PyTorch using onnx2torch. Specifically, the model contains a Clip operation where the min and max values are dynamic, and it appears that onnx2torch doesn't support dynamic min/max values in this operation.

Here is the error message I received:

KeyError: '' ... NotImplementedError: Dynamic value of min/max is not implemented

Expected Behavior

onnx2torch should support dynamic min and max values for the Clip operation. If dynamic values are not supported at the moment, it would be helpful to either handle this scenario gracefully or provide an alternative way to manage these cases.

Steps to Reproduce

  1. Convert an ONNX model that includes a Clip operation with dynamic min and max values. (like CosyVoice speech tokenizer)

  2. Use the following code to trigger the error:

   from onnx2torch import convert
   torch_model = convert("/path/to/model.onnx")

Environment Details

onnx2torch version: 1.5.15 Python version: 3.9.0 PyTorch version: 2.2.2

gary920209 avatar Oct 11 '24 05:10 gary920209

@gary920209 Hi Gary, I'm having the same issue convert a yolo8 onnx model to pt. Did you manage to find a solution?

LayanCS avatar Feb 11 '25 12:02 LayanCS

Any update?

hbellafkir avatar Feb 18 '25 14:02 hbellafkir

I had the same issue with a quantized Mask-RCNN: NotImplementedError: Dynamic value of min/max is not implemented

Env: onnx2torch version: 1.5.15 pytorch version: 2.8.0+cu128 Python version: 3.12.7

Great project btw, thank you!

baldurgaldur avatar Nov 07 '25 14:11 baldurgaldur