MCPcopy
hub / github.com/tinygrad/tinygrad / _align_left

Function _align_left

tinygrad/uop/ops.py:50–52  ·  view source on GitHub ↗
(*shapes:tuple[sint, ...])

Source from the content-addressed store, hash-verified

48def smin(*lst) -> sint: return _suop(argfix(*lst), UOp.minimum, min)
49def srender(x:sint) -> str: return x.render() if isinstance(x, UOp) else str(x)
50def _align_left(*shapes:tuple[sint, ...]) -> tuple[tuple[sint, ...], ...]:
51 max_dim = max(len(s) for s in shapes)
52 return tuple((1,)*(max_dim-len(s))+s for s in shapes)
53def _broadcast_shape(*shapes:tuple[sint, ...]) -> tuple[sint, ...]:
54 shaped_aligned_left = _align_left(*shapes)
55 ret = tuple(0 if 0 in nth_dim_sizes else smax(nth_dim_sizes) for nth_dim_sizes in zip(*shaped_aligned_left))

Callers 4

_broadcast_toMethod · 0.90
expandMethod · 0.90
repeatMethod · 0.90
_broadcast_shapeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…