(ctx, grad_output)
| 37 | |
| 38 | @staticmethod |
| 39 | def backward(ctx, grad_output): |
| 40 | x, _ = ctx.saved_tensors |
| 41 | pos_mask_1 = (x > 0).type_as(grad_output) |
| 42 | pos_mask_2 = (grad_output > 0).type_as(grad_output) |
| 43 | y = torch.mul(grad_output, pos_mask_1) |
| 44 | grad_input = torch.mul(y, pos_mask_2) |
| 45 | return grad_input |
| 46 | |
| 47 | |
| 48 | class _GradReLU(torch.nn.Module): |