ATen icon indicating copy to clipboard operation
ATen copied to clipboard

[Scalars] Remove Tensor + Scalar overloads, and dispatch correctly in Tensor + Tensor

Open zdevito opened this issue 6 years ago • 0 comments

Current we have two overloads for things where 0-dim tensors can occur:

Tensor + Tensor Tensor + Scalar

Instead we should only have Tensor + Tensor. However, we still need to maintain good performance. This means that in case where we have GPUTensor + CPUScalar, we should be calling the THC_addc method and not the generic add.

In addition to modifying ATen to remove the Tensor +Scalar variant, this commit needs to add the appropriate casting behavior for 0-dim tensors:

In the places we modify we need the concept of a relocatable 0-dim Tensor. Unlike in other locations in these special cases a 0-dim tensor will first be automatically converted to the right backend, and the right type if it is not already. The rest of the function should then proceed as it would have if the 0-dim Tensor was already the right type/backend.

zdevito avatar Oct 20 '17 21:10 zdevito