Solved by ptrblck in post #2 
              
              
                Due to floating point precision you might get small errors (usually at ~1e-6), so I would suggest to compare the results with torch.allclose (and specifying the tolerance manually, if necessary). 
A direct comparison for floating point numbers is often not the best idea.