Skip to content

Commit

Permalink
[IR] Use structural equal for Range equality (apache#15664)
Browse files Browse the repository at this point in the history
This PR adds a small change to verify equality of `tvm.ir.Range` as a
structural equal. This assumes that in most cases, comparing two
`Range`s means to compare its `min` and `extent` as opposed to the
actual Range object handle.
  • Loading branch information
quic-sanirudh authored Sep 5, 2023
1 parent 476d9d1 commit 04ee895
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/tvm/ir/expr.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,9 @@ def from_min_extent(min_value, extent, span=None):
The constructed range.
"""
return _ffi_api.Range_from_min_extent(min_value, extent, span)

def __eq__(self, other):
return tvm.ir.structural_equal(self, other)

def __ne__(self, other):
return not self.__eq__(other)

0 comments on commit 04ee895

Please sign in to comment.