Solved by singleroc in post #4 
              
              
                Hi, I found out the reason for the issue. It is caused by the grad_output to be not contiguous. After adding grad_output = grad_output.contiguous(), the error is gone.