The maximal difference is ~1.7e-7, which is due to limited floating point precision using FP32.
If you need more precision, you could use DoubleTensors, but your manual implementation should work fine.