From e7a49e84c84e6d6657b14fbfefd3dcc79a390aa6 Mon Sep 17 00:00:00 2001 From: Roelof van Dijk <3604013+roelofvandijk@users.noreply.github.com> Date: Fri, 29 Sep 2023 20:07:24 +0200 Subject: [PATCH] perf: assert behind if is not optimized (#1847) * perf: assert behind if is not optimized * Update helpers.py --------- Co-authored-by: Roelof van Dijk Co-authored-by: George Hotz <72895+geohot@users.noreply.github.com> --- tinygrad/shape/view.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tinygrad/shape/view.py b/tinygrad/shape/view.py index d577b68acc..77b30aa23d 100644 --- a/tinygrad/shape/view.py +++ b/tinygrad/shape/view.py @@ -89,8 +89,7 @@ class View: assert all(is_sym_int(x) and x > 0 for x in new_shape), f"shape must be symbolic ints and can't contain 0 or negative numbers {new_shape}" # only check size for int shapes. we don't check symbolic here as long as the reshape itself can be done - if all_int(self.shape) and all_int(new_shape): - assert prod(self.shape) == prod(new_shape), f"can't reshape {self.shape} -> {new_shape}" + assert prod(self.shape) == prod(new_shape) if all_int(self.shape + new_shape) else True, f"can't reshape {self.shape=} -> {new_shape=}" # after the asserts, it's okay to check contiguous if self.contiguous: return View.create(new_shape)