Tensoriterator type promotion fixes (#28961)
* preserve original tensoriterator behavior when not explicitly promoting
Summary:
Cherry-picking of https://github.com/pytorch/pytorch/pull/28231 to
1.3.1 branch.
Fix: https://github.com/pytorch/pytorch/issues/28010
A mixed-type index assignment that would have been an error in 1.2 was unintentionally made possible (with incorrect results) in 1.3. This PR restores the original behavior.
This is BC-breaking because:
```
a = torch.ones(5, 2, dtype=torch.double)
b = torch.zeros(5, dtype=torch.int)
a[:, [1]] = b.unsqueeze(-1)
```
now raises an error (as in 1.2) whereas it did not in 1.3.
* Compute correct strides after type promotion (#28253)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/28253
Instead of trying to fix strides after changing dtypes, wait until after
promotion to set them.
fixes: https://github.com/pytorch/pytorch/issues/27824
fixes: https://github.com/pytorch/pytorch/issues/28502
Test Plan: Imported from OSS
Differential Revision: D18124950
Pulled By: nairbv
fbshipit-source-id: e4db90b2a6bb0f5d49cb388e0cd1971303c6badd