RuntimeError: PyFunction::apply: expected Variable or None (got torch.cuda.ZFloatTensor)

I have written a custom function class. when calling backward I am getting the error as in the heading. The error occurs in PyFunction::apply. Could someone please explain why I need to return a Variable and cannot return a normal Tensor? Why are the Tensors not wrapped automatically to Variables like it is done for the input arguments?

1 Like