From d38367b56171c7ddc6d5ae58efcc64e74ca34a6a Mon Sep 17 00:00:00 2001 From: George Hotz Date: Sun, 25 Oct 2020 14:35:04 -0700 Subject: [PATCH] cleaner relu --- tinygrad/ops.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tinygrad/ops.py b/tinygrad/ops.py index 644b32f9..25e219d6 100644 --- a/tinygrad/ops.py +++ b/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)