fix uop gc

This commit is contained in:
2025-09-30 19:08:35 +08:00
parent d8bb679a3a
commit 7eee206177
2 changed files with 7 additions and 2 deletions
+1
View File
@@ -63,6 +63,7 @@ if __name__ == "__main__":
views_to_valid_uop.cache_clear()
new_uops = uops_allocated()
print_uops()
gc.collect()
new_uops_gc = uops_allocated()
print(f"{t.__name__:30s}: {new_uops:3d} -> {new_uops_gc:3d}")
+6 -2
View File
@@ -217,8 +217,7 @@ class UOp(MathTrait, metaclass=UOpMetaClass):
# determine what ranges this is in
@functools.cached_property
def ranges(self) -> dict[UOp, None]:
if self.op is Ops.RANGE: return {self:None}
def _ranges(self) -> dict[UOp, None]:
ret: dict[UOp, None] = {}
if self.op in range_start.keys():
for s in self.src[:range_start[self.op]]: ret.update(s.ranges)
@@ -228,6 +227,11 @@ class UOp(MathTrait, metaclass=UOpMetaClass):
for s in self.src: ret.update(s.ranges)
return ret
@property
def ranges(self) -> dict[UOp, None]:
if self.op is Ops.RANGE: return {self:None}
return self._ranges
# *** uop evaluation ***
def simplify(self, tracked=False):