Skip to content

Commit

Permalink
remove a leading 1 check in _reshape_mask [pr] (tinygrad#8327)
Browse files Browse the repository at this point in the history
the only possible mask for it is either (0, 0) or (0, 1). so the logic is no-op
  • Loading branch information
chenyuxyz authored Dec 19, 2024
1 parent 8a8eaa1 commit accc186
Showing 1 changed file with 0 additions and 4 deletions.
4 changes: 0 additions & 4 deletions tinygrad/shape/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]:
Expand Down

0 comments on commit accc186

Please sign in to comment.