You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by "swjng (via GitHub)" <gi...@apache.org> on 2026/04/09 08:22:11 UTC
[PR] [BugFix][Relax] Fix ONNX Clip converter for opset 11-12 [tvm]
swjng opened a new pull request, #19375:
URL: https://github.com/apache/tvm/pull/19375
## Description
ONNX changed the Clip operator from attribute-based min/max (opset 1-10) to input-based min/max (opset 11+). The Relax ONNX frontend only had `_impl_v1` (attributes) and `_impl_v13` (inputs), so opset 11-12 models were dispatched to `_impl_v1` which ignores the input-based min/max and falls back to `-inf`/`inf` defaults, making Clip a no-op.
This caused **silent numerical divergence** in any opset 11-12 model using Clip/ReLU6 (e.g. MobileNetV2-12 from the ONNX Model Zoo).
### Root cause
`OnnxOpConverter.get_converter()` selects the largest `_impl_v*` version <= the model opset. With only `v1` and `v13`, opset 11-12 mapped to `v1`, which reads min/max from attributes — but opset 11+ passes them as inputs.
### Fix
Add `_impl_v11` that delegates to `_impl_v13`.
### Results (MobileNetV2, opset 12)
| Metric | Before | After |
|--------|:---:|:---:|
| max abs diff vs ORT | 1.72e+06 | **8.58e-06** |
| cosine similarity | 0.222 | **1.000** |
| Top-5 match | No | **Yes** |
## Testing
```bash
pytest tests/python/relax/test_frontend_onnx.py -k "clip" -v
```
All 6 existing Clip tests pass (opset 6 and 13+). The fix only affects opset 11-12 dispatch.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] [BugFix][Relax] Fix ONNX Clip converter for opset 11-12 [tvm]
Posted by "swjng (via GitHub)" <gi...@apache.org>.
swjng commented on PR #19375:
URL: https://github.com/apache/tvm/pull/19375#issuecomment-4212858136
Note: #19376 fixes a related but independent bug in `get_converter()` itself — an index underflow that causes 14 operators to silently use the wrong converter for opset < min implemented version. That fix is necessary but not sufficient for Clip, because Clip has `_impl_v1` (so the underflow doesn't trigger), and the issue here is that `_impl_v1` reads min/max from attributes while opset 11+ passes them as inputs. Both PRs are needed.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org
Re: [PR] [BugFix][Relax] Fix ONNX Clip converter for opset 11-12 [tvm]
Posted by "tlopex (via GitHub)" <gi...@apache.org>.
tlopex merged PR #19375:
URL: https://github.com/apache/tvm/pull/19375
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: discuss-archive-unsubscribe@tvm.apache.org
For additional commands, e-mail: discuss-archive-help@tvm.apache.org