tiny View.unbind cleanup [run_process_replay] (#5355)

`Variable.val` asserts if it's None, so unbind does not need to check if `.val` is not None
This commit is contained in:
chenyu
2024-07-09 23:37:53 -04:00
committed by GitHub
parent cc80005377
commit f01192b8cd

View File

@@ -121,7 +121,7 @@ class View:
@functools.lru_cache(None) # pylint: disable=method-cache-max-size-none
def unbind(self) -> Tuple[View, Dict[Variable, int]]:
var_unboundvar_val = [(v, v.unbind()) for v in self.vars() if v.val is not None]
var_unboundvar_val = [(v, v.unbind()) for v in self.vars()]
unbound_vars = {v:uv for v,(uv,_) in var_unboundvar_val}
new_shape = tuple([s if isinstance(s, int) else s.substitute(unbound_vars) for s in self.shape])
new_strides = tuple([s if isinstance(s, int) else s.substitute(unbound_vars) for s in self.strides])