However, after my implementation of forward(self, input), during forward pass, the input, which is a Variable, is converted into a floatTensor. Since my function is a loss function, the output becomes just a float number. Pytorch throw out an error: RuntimeError: data must be a Tensor

for which I want to compute the determinant of an input matrix. I got the same fail message RuntimeError: data must be a Tensor which I think comes from the output that turned out to be a float number. Any suggestions?

-------------------------- update ------------------------------------
My problem has been solved by changing the type of output to torch tensor:

@staticmethod
def forward(ctx, x):
output = torch.potrf(x).diag().prod()**2
output = torch.Tensor([output]).cuda() # NEW line
ctx.save_for_backward(x, output)
return output