gemini-code-assist[bot] commented on code in PR #19871:
URL: https://github.com/apache/tvm/pull/19871#discussion_r3457534810
##########
python/tvm/tirx/transform/common.py:
##########
@@ -63,6 +62,10 @@ def mutate_buffer(self, buffer: Buffer):
self.buffer_attr_var_mutated = False
new_data = self.visit_expr(buffer.data)
new_shape = [self.visit_expr(expr) for expr in buffer.shape]
+ new_strides = [self.visit_expr(expr) for expr in buffer.strides]
Review Comment:

In TVM, `buffer.strides` can be `None` (or null on the C++ side, which
translates to `None` in Python) when the buffer is contiguous and no explicit
strides are defined. Iterating over `buffer.strides` directly without a `None`
check can raise a `TypeError: 'NoneType' object is not iterable`. Adding a
defensive check similar to `buffer.elem_offset` prevents potential runtime
crashes.
```python
new_strides = (
[self.visit_expr(expr) for expr in buffer.strides]
if buffer.strides is not None
else None
)
```
--
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]