The GitHub Actions job "Lint" on tvm.git/main has succeeded.
Run started by GitHub user tlopex (triggered by tlopex).

Head commit for run:
1720d305ae785cc33fa453a3d0f7eb91a0073534 / Javier De Jesus 
<[email protected]>
[Relax][ONNX] Fix TopK scalar K extraction in from_onnx (#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

Resolve `k` with `get_constant(inputs[1], params)` and extract the
scalar with `.item()`, matching the `Trilu` and `Reshape` converters in
the same file. `get_constant` also handles `k` arriving as a parameter
when `keep_params_in_input=True`.

### 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

Report URL: https://github.com/apache/tvm/actions/runs/26109314914

With regards,
GitHub Actions via GitBox


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to