Ok after trying a few things.
-
In order to make sure
func
would not be included in the Autograd graph, I all had to do was to passx.data
to it instead ofx
:loss_y = second_loss(func(x.data), y)
This way I won’t have to think if I should return None
for it backward or not, backward will simply not be called by autograd.
- It is Ok if we only bind
forward
for a cuda extension, it works just fine