Is there any document/guideline for PyTorch ops and data type conversions and promotion rules? There is a document at Tensor Attributes — PyTorch 1.10.1 documentation, however it does not cover some of the op specific cases. For example, add for int32 arguments returns an int32 dtype tensor, but div returns a float32 tensor -



a = torch.ones(4, dtype=torch.int32)
b = torch.ones(4, dtype=torch.int32)
add = a + b
add.dtype
torch.int32




div = a / b
div.dtype
torch.float32




torch.result_type(a, b) ← This doesn’t return the correct result dtype for div
torch.int32



Similarly, for logical comparator ops like eq, the result tensor is boolean but for in-place eq_, the result tensor type is same as the original. Also, eq_ doesn’t seem to do a dtype conversion -



ai.dtype
torch.int32




b.dtype
torch.float32




c = torch.eq(ai, b) ← this works fine
ai.eq_(b) ← this doesn’t work
Traceback (most recent call last):
File “”, line 1, in 
RuntimeError: Expected object of scalar type int but got scalar type float for argument ‘other’



It would be great if anyone can share any document/guideline on the rules covering all these cases.