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 "viiccwen (via GitHub)" <gi...@apache.org> on 2026/07/09 16:18:37 UTC
[PR] [Fix][Relax][ONNX] Import TopK indices as int64 [tvm]
viiccwen opened a new pull request, #19973:
URL: https://github.com/apache/tvm/pull/19973
Fixes #19972
ONNX specifies that the second output of TopK, `indices`, has element type
`int64`, and the ONNX TopK operator spec constrains the index tensor type to
`tensor(int64)`: https://onnx.ai/onnx/operators/onnx__TopK.html
The Relax ONNX frontend previously called `relax.op.topk` without
specifying the output indices dtype, so Relax used its default `int32` indices.
This can make otherwise valid ONNX graphs fail during import when the TopK
indices are consumed by later integer/index operations that use ONNX's usual
`int64` constants. One example is `TopK -> Div`, where Relax rejects the binary
operation because the imported TopK indices are `int32` while the divisor is
`int64`.
This patch passes `dtype="int64"` when importing ONNX TopK, matching the ONNX
operator spec. It also updates the existing TopK frontend test to check output
dtypes, so the imported indices must match ONNX Runtime's `int64` output.
Verification:
- `TVM_LIBRARY_PATH="$(pwd)/build/lib" uv run --no-sync python -m pytest tests/python/relax/test_frontend_onnx.py::test_topk -q`
--
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] [Fix][Relax][ONNX] Import TopK indices as int64 [tvm]
Posted by "yongwww (via GitHub)" <gi...@apache.org>.
yongwww closed pull request #19973: [Fix][Relax][ONNX] Import TopK indices as int64
URL: https://github.com/apache/tvm/pull/19973
--
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] [Fix][Relax][ONNX] Import TopK indices as int64 [tvm]
Posted by "tlopex (via GitHub)" <gi...@apache.org>.
tlopex merged PR #19973:
URL: https://github.com/apache/tvm/pull/19973
--
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] [Fix][Relax][ONNX] Import TopK indices as int64 [tvm]
Posted by "viiccwen (via GitHub)" <gi...@apache.org>.
viiccwen commented on PR #19973:
URL: https://github.com/apache/tvm/pull/19973#issuecomment-4927311115
cc @guan404ming. 🙌
--
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] [Fix][Relax][ONNX] Import TopK indices as int64 [tvm]
Posted by "viiccwen (via GitHub)" <gi...@apache.org>.
viiccwen commented on PR #19973:
URL: https://github.com/apache/tvm/pull/19973#issuecomment-4942706286
Thx @guan404ming, @tlopex for reviewing!
--
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] [Fix][Relax][ONNX] Import TopK indices as int64 [tvm]
Posted by "guan404ming (via GitHub)" <gi...@apache.org>.
guan404ming commented on PR #19973:
URL: https://github.com/apache/tvm/pull/19973#issuecomment-4933085624
LGTM but the ci seems not worked for now.
cc @tqchen
--
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