javierdejesusda commented on code in PR #19573:
URL: https://github.com/apache/tvm/pull/19573#discussion_r3254044414


##########
python/tvm/relax/frontend/onnx/onnx_frontend.py:
##########
@@ -4231,7 +4231,7 @@ def _impl_v11(cls, bb, inputs, attr, params):
         k = inputs[1]
         if not isinstance(k, relax.Constant):
             raise ValueError("TopK k must be a constant")
-        k = int(k.data.numpy())
+        k = int(k.data.numpy().item())

Review Comment:
   Applied get_constant(inputs[1], params) before the constant check, so TopK 
now matches the Trilu/Reshape pattern and handles k arriving as a parameter 
when keep_params_in_input=True.
   
   The Sequence* ops are not the same issue. ONNX mandates position for 
SequenceAt/SequenceErase/SequenceInsert as a 0-D scalar, and int() on a 0-D 
array works on all supported NumPy versions, whereas TopK's K is spec'd as a 
1-D tensor, which is what triggered the crash here. The existing 
test_sequence_erase/test_sequence_insert/test_sequence_at pass on main against 
the current code, so there is no latent bug there and no follow-up is 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: [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]

Reply via email to