From accc186c8b3dd0d72cc2af642b4bb3d1e14754ca Mon Sep 17 00:00:00 2001 From: chenyu Date: Wed, 18 Dec 2024 19:30:10 -0500 Subject: [PATCH] remove a leading 1 check in _reshape_mask [pr] (#8327) the only possible mask for it is either (0, 0) or (0, 1). so the logic is no-op --- tinygrad/shape/view.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tinygrad/shape/view.py b/tinygrad/shape/view.py index b49876ea07450..c2144f15919ef 100644 --- a/tinygrad/shape/view.py +++ b/tinygrad/shape/view.py @@ -68,10 +68,6 @@ def _reshape_mask(_mask:Optional[Tuple[Tuple[sint, sint], ...]], old_shape:Tuple if mask != (0, old_dim) and next_mask[1] - next_mask[0] != 1: return None mask, old_dim = (next_mask[0] * old_dim + l, (next_mask[1] - 1) * old_dim + r), old_dim * next(r_shape, 1) - # TODO: do we need this? - for mask in r_masks: # if the old shape has leading 1s, need to make sure their mask is (0,1) - if mask != (0, 1): return ((0, 0),) * len(new_shape) # invalid mask - return tuple(reversed(new_mask)) def unravel(shape:Tuple[sint, ...], offset:sint) -> List[sint]: