How inplace sin op work? It really save memory when requires_grad is False?

Hi, I have a question how inplace sin could use output_value to calculate input_grad?

As the function: y = sin(x),x_grad = grad * sign * sqrt(1 - sin^2(x)). But we don’t know that the sign is positive or negative.

It looked as though it must save the value of original x tensor. But it can’t save memory in this way.

Can we do the inplace operator and save memory in the same time?

Hi,

I am afraid you can’t no. You have to save something of the size of the input. (either the sign or the input itself). So in core, we save a clone of the input.