Speed up sum backward pass
MODIFY
tinygrad/opsgpu.py
tinygrad/opsgpu.py
@@ -104,8 +104,7 @@ class Sum(Function):
@staticmethod
def backward(ctx, grad_output):
input, = ctx.saved_tensors
- ret = Tensor(grad_output).cpu().data * np.ones(input.shape, dtype=input.dtype)
- return Tensor(ret).cuda().data
+ return binary_op(ctx, 'res_g[gid] = b_g[0];', input, grad_output) # Quick hack for fill
register('sum', Sum, gpu=True)
class Dot(Function):

Speed up sum backward pass (#54)

Co-authored-by: holonomicjl <58403584+holonomicjl@users.noreply.github.com>