gemini-code-assist[bot] commented on code in PR #20039:
URL: https://github.com/apache/tvm/pull/20039#discussion_r3619806407
##########
python/tvm/topi/nn/conv2d.py:
##########
@@ -859,8 +859,10 @@ def conv(
if auto_scheduler_rewritten_layout:
raise RuntimeError("LEGACY-FLOW triggered, to be removed")
- assert in_channel % groups == 0, "input channels must divide group size"
- assert num_filter % groups == 0, "output channels must divide group size"
+ if isinstance(in_channel, int):
+ assert in_channel % groups == 0, "input channels must divide group
size"
+ if isinstance(num_filter, int):
+ assert num_filter % groups == 0, "output channels must divide group
size"
Review Comment:

In TVM, constant dimensions can sometimes be represented as `tvm.tir.IntImm`
objects rather than Python `int`s. Checking only `isinstance(..., int)` will
cause the divisibility assertions to be silently skipped for these constant
`IntImm` values.
By checking for `tvm.tir.IntImm` as well and casting to `int(...)` before
the modulo operation, we ensure that the divisibility check is still executed
and validated for all constant channel sizes, improving the robustness of the
operator's input validation.
```suggestion
if isinstance(in_channel, (int, tvm.tir.IntImm)):
assert int(in_channel) % groups == 0, "input channels must divide
group size"
if isinstance(num_filter, (int, tvm.tir.IntImm)):
assert int(num_filter) % groups == 0, "output channels must divide
group size"
```
--
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]