gemini-code-assist[bot] commented on code in PR #19858:
URL: https://github.com/apache/tvm/pull/19858#discussion_r3449154937
##########
python/tvm/relax/transform/legalize_ops/index.py:
##########
@@ -36,11 +37,17 @@ def _take(bb: BlockBuilder, call: Call) -> Expr:
@register_legalize("relax.strided_slice")
def _strided_slice(bb: BlockBuilder, call: Call) -> Expr:
def _relax_tuple_to_tir(relax_tuple):
+ if isinstance(relax_tuple, Tuple):
+ output = []
+ for field in relax_tuple.fields:
+ assert isinstance(field, PrimValue)
+ output.append(field.value)
+ return output
+
output = []
for field in relax_tuple.ty.fields:
assert isinstance(field, PrimType)
- assert field.value is not None
- output.append(field.value)
+ return None
return output
Review Comment:

In `_relax_tuple_to_tir`, returning `None` inside the loop on the first
iteration prevents the validation of subsequent fields in the tuple type. If a
tuple type contains a mix of `PrimType` and other invalid types, the invalid
types after the first element will not trigger the assertion.
We should validate all fields in the loop first, and then return `None` if
the tuple is non-empty.
```suggestion
for field in relax_tuple.ty.fields:
assert isinstance(field, PrimType)
if relax_tuple.ty.fields:
return None
return []
```
--
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]