MCPcopy
hub / github.com/tinygrad/tinygrad / broadcast_to_input

Function broadcast_to_input

tinygrad/gradient.py:8–8  ·  view source on GitHub ↗
(x)

Source from the content-addressed store, hash-verified

6
7def reduce_gradient(ctx:UOp, ret:UOp, op:Ops):
8 def broadcast_to_input(x): return x.reshape(x.shape+(1,)*(len(ret.src[0].shape)-len(x.shape))).expand(ret.src[0].shape)
9 if op == Ops.ADD: return (broadcast_to_input(ctx),)
10 if op == Ops.MAX:
11 assert ret.op is Ops.REDUCE, "only works on REDUCE"

Callers 1

reduce_gradientFunction · 0.85

Calls 2

expandMethod · 0.80
reshapeMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…