javierdejesusda opened a new pull request, #19573: URL: https://github.com/apache/tvm/pull/19573
### Root Cause `TopK._impl_v11` extracted `k` with `int(k.data.numpy())`. ONNX emits `K` as a single-element 1-D tensor constant, so `numpy()` returns a 1-D array and `int()` raises `TypeError: only 0-dimensional arrays can be converted to Python scalars`, failing conversion of any model with a `TopK` node. ### Solution Extract the scalar with `.item()`, matching the `Trilu` converter in the same file, which already uses `int(k.data.numpy().item())` for the same kind of constant scalar input. ### Test Plan `test_topk` in `tests/python/relax/test_frontend_onnx.py` already builds `K` as a single-element 1-D INT64 constant, so it exercises this path. `.item()` returns the scalar for both single-element 1-D and 0-d constants. ### Issue Fixes #19571 -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
