I’m implementing something like ReLU:
class My_ReLU(nn.Module):

    def __init__(self):
        super(My_ReLU, self).__init__()

    def forward(self, x):

        x[x < 0] *= 0

        return x

I found  my code is extremely slow compared to pytorch officially ReLU 1 mainly caused by x[x < 0] *= 0.
So is there faster way for conditional indexing?
Why is the official ReLU so fast?