Issue with FFI extension backward function

Hello everyone,

I created a C extension based on the FFI tutorial in “Custom C extensions for pytorch” (http://pytorch.org/tutorials/advanced/c_extension.html). I would like to be able to call the backward function but it returns the following error:

`RuntimeError: there are no graph nodes that require computing gradients`

Actually, even trying to call backward() in the provided example code returns an error on my machine. I tried adding the following commands at the end of the main.py function.

model = MyNetwork()
out = model(input1, input2)
out.backward()

Am I doing something wrong? Any idea how to make this work?
Any help would be appreciated.

Thanks,

Hi,

This error is because no element with requires_grad=True has been used in the computations.
This may be due to the fact that you model contains no learnable parameter and your inputs does not require grad.
Or it can be due to the fact that out is independent of all the elements that requires_grad=True