gemini-code-assist[bot] commented on code in PR #19961:
URL: https://github.com/apache/tvm/pull/19961#discussion_r3534444947


##########
src/relax/analysis/tir_op_pattern_kind.cc:
##########
@@ -408,6 +408,9 @@ bool HasReshapePattern(const PrimFunc& func) {
 
       ffi::Map<tirx::Var, Range> var_range;
       for (const IterVar& v : block->iter_vars) {
+        if (is_zero(v->dom->extent)) {
+          return;
+        }

Review Comment:
   ![medium](https://www.gstatic.com/codereviewagent/medium-priority.svg)
   
   Using `is_zero(v->dom->extent)` only checks if the extent is a literal 
constant zero. If the extent is a symbolic expression that simplifies to zero 
(e.g., `0 * n`), `is_zero` will return `false`, which could still lead to a 
division-by-zero crash in the subsequent logic.\n\nUsing the analyzer 
`ana_->CanProveEqual(v->dom->extent, 0)` is more robust as it leverages the 
analyzer's simplification and proving capabilities to detect any expressions 
that evaluate to zero.
   
   ```c
           if (ana_->CanProveEqual(v->dom->extent, 0)) {\n          return;\n   
     }
   ```



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