@albanD why do we need to use save_for_backwards for input tensors only ? I just tried to pass one input tensor from forward() to backward() using ctx.tensor = inputTensor in forward() and inputTensor = ctx.tensor in backward() and it seemed to work.
I appreciate your answer since I’m currently trying to really understand when to use ctx rather than save_for_backward . Another post 28 tells us memory leak isn’t an issue any more , and concludes on my question.
In addition, reading this other post suggests “earlier torch versions it was not possible to save_for_backward an intermediate result, only inputs to the forward function, but that seems to be no longer the case.”
An actual limit would be the need for the saved value to be a variable (in the sense of pytorch tensor) in the case of save_for_backward .