Thanks a lot! I also had a question about the Autograd of torch::jit::script::Module of C++ API.
I try to load a trained pytorch model into C++(let’s call this model in C++ “M”), first I do the forward process by:
out = M(input);
loss = loss_function(out, ground-truth)
then I tried to use it do backward propagation to calculate the grad of it’s input tensor “input”. However I found that the .grad of “input” is always zero. And the .grad_fn of “output” is a “nullptr”.
Any solutions for this?
Many thanks!