The behavior is inherited from Lua Torch. With an operation involving a Python number and a Tensor, the number is cast to the Tensor’s type (which rounds 0.5 to 0 in this case).
We plan to change the behavior in the future. It’s tracked here:

  
      github.com/pytorch/pytorch
  
  
    



Issue: Proposal: type promotion logic (torch.result_type) 11


	
	opened by colesbury
	on 2018-07-17
	
	
	


This proposes an algorithm for computing the result type of a mixed-type operation like torch.add. The function will be exposed to...