@smth @Paralysis I have codes that look like:
    @staticmethod
    def forward(ctx, x):
        output = torch.potrf(x).diag().prod()**2
        ctx.save_for_backward(x, output)
        return output 

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