MCPcopy
hub / github.com/tinygrad/tinygrad / ipad

Method ipad

tinygrad/tensor.py:1484–1486  ·  view source on GitHub ↗
(t, i, amt)

Source from the content-addressed store, hash-verified

1482 def is_pow2(v): return v > 0 and v & (v - 1) == 0
1483 # pad dimension i to amt with invalids
1484 def ipad(t, i, amt):
1485 shape = (None,)*i + (amt,) + (None,)*(t.ndim-i-1)
1486 return Tensor(True, device=t.device).expand(t.shape).pad_to(shape).where(t.pad_to(shape), Invalid) if amt != t.shape[i] else t
1487 # align a dimension, use at to specify the dimension to pad in, defaults to first
1488 def pad_align(t, dim, at=None, force=False):
1489 # align to 64 pixels when height is real, otherwise 64 bytes is sufficient

Callers

nothing calls this directly

Calls 4

TensorClass · 0.85
pad_toMethod · 0.80
expandMethod · 0.80
whereMethod · 0.45

Tested by

no test coverage detected