Hi,
The gradient we want to compute here is indeed: 1 if input > 0 and 0 if inputs <= 0.
The nice thing is that inputs <= 0 <=> relu(inputs) = 0.
So we can actually compute the gradient based on the result with grad_input[result == 0] = 0 (or with <=, that would give the same result as result >=0).