gemini-code-assist[bot] commented on code in PR #19613:
URL: https://github.com/apache/tvm/pull/19613#discussion_r3304861890
##########
python/tvm/ir/base.py:
##########
@@ -207,7 +208,7 @@ def structural_equal(lhs, rhs, map_free_vars=False):
"""
lhs = tvm.runtime.convert(lhs)
rhs = tvm.runtime.convert(rhs)
- return bool(_ffi_node_api.StructuralEqual(lhs, rhs, False, map_free_vars))
# type: ignore # pylint: disable=no-member
+ return _tvm_ffi_api.GetFirstStructuralMismatch(lhs, rhs, map_free_vars,
False) is None # type: ignore # pylint: disable=no-member
Review Comment:

Using `GetFirstStructuralMismatch` to check for structural equality is
inefficient because it tracks and constructs the `AccessPath` mismatch pair
during the traversal, which incurs extra allocation and overhead. Since
`tvm-ffi` provides a direct `StructuralEqual` API, we should use it instead for
a simple boolean check to allow fast early-exiting without path-tracking
overhead.
```suggestion
return _tvm_ffi_api.StructuralEqual(lhs, rhs, map_free_vars) # type:
ignore # pylint: disable=no-member
```
--
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]