From d921169edd0ee63e0bd96e6a60e77bd05f55967d Mon Sep 17 00:00:00 2001 From: Anirudh Sundar Date: Mon, 4 Sep 2023 15:03:14 +0530 Subject: [PATCH] [IR] Use structural equal for Range equality 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. --- python/tvm/ir/expr.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/tvm/ir/expr.py b/python/tvm/ir/expr.py index 5a83d8e5d92e..f0f2245e7f62 100644 --- a/python/tvm/ir/expr.py +++ b/python/tvm/ir/expr.py @@ -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)