cleaner relu
MODIFY
tinygrad/ops.py
tinygrad/ops.py
@@ -45,8 +45,7 @@ class ReLU(Function):
@staticmethod
def backward(ctx, grad_output):
input, = ctx.saved_tensors
- grad_input = grad_output.copy()
- grad_input[input < 0] = 0
+ grad_input = grad_output * (input >= 0)
return grad_input
register('relu', ReLU)

cleaner relu