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


##########
python/tvm/relax/script/parser/parser.py:
##########
@@ -168,30 +213,25 @@ def is_recursive(node: doc.FunctionDef) -> bool:
 
 
 def collect_symbolic_var_from_prelude(
-    self: Parser, node: doc.FunctionDef, symbolic_vars: dict[str, tirx.Var]
-) -> dict[str, tirx.Var]:
+    self: Parser, node: doc.FunctionDef, symbolic_vars: dict[str, tvm.ir.Var]
+) -> dict[str, tvm.ir.Var]:
     prelude_vars = {}
     for stmt in node.body:
-        if isinstance(stmt, doc.Assign) and all(
-            isinstance(target, doc.Name) and target.id in symbolic_vars for 
target in stmt.targets
-        ):
-            values = self.eval_expr(stmt.value)
-
-            try:
-                iter(values)
-            except TypeError:
-                values = [values]
-
-            assert len(stmt.targets) == len(values)
-            for target, value in zip(stmt.targets, values):
-                name = target.id
-                prelude_vars[name] = value
+        if isinstance(stmt, doc.Assign) and len(stmt.targets) == 1:
+            declarations = 
collect_symbolic_var_declaration_nodes(stmt.targets[0], stmt.value)
+            for name, value_node in declarations.items():
+                if name not in symbolic_vars:
+                    continue
+                declared_var = self.eval_expr(value_node)
+                if tvm.ir.is_prim_var(declared_var) and declared_var.ty == 
symbolic_vars[name].ty:

Review Comment:
   ![high](https://www.gstatic.com/codereviewagent/high-priority.svg)
   
   Comparing `tvm.ir.Type` instances using `==` checks for pointer/reference 
equality rather than structural equality. Since `declared_var.ty` and 
`symbolic_vars[name].ty` are constructed independently, they will be different 
instances of `PrimType` (even if they both represent `int64`), causing this 
check to always evaluate to `False`. Use `tvm_ffi.structural_equal` to perform 
a proper structural comparison.
   
   ```suggestion
                   if tvm.ir.is_prim_var(declared_var) and 
tvm_ffi.structural_equal(declared_var.ty, symbolic_vars[name].ty):
   ```



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