Repository: pytorch
Issue: It seems that `torch.Tensor.addmv` and `torch.Tensor.addr` will check some inputs' dtype if and only if in `backward()`
Labels: module: autograd,triaged,module: complex,module: type promotion,module: linear algebra,actionable,complex_autograd

### 🐛 Describe the bug


For some cases where the dtypes of inputs are different, `torch.Tensor.addr` and `torch.Tensor.addmv` do not seem to detect this data type inconsistency in forward, but will throw out an Error in backward.
It is not sure whether this forward process will introduce unknown dtype-related problems in subsequent calculations.
I'm wondering if this is a feature of these functions or if the checks for datatype consistency need to be tightened up in the forward process.

This issue should be related to [#76785](https://github.com/pytorch/pytorch/issues/76785).

### To Reproduce
```python

import torch

input0 = torch.rand([3, 2], dtype=torch.complex128, requires_grad=True)
input1 = torch.rand([3], dtype=torch.float64, requires_grad=True)
input2 = torch.rand([2], dtype=torch.complex128, requires_grad=True)

def test():
    tmp_result= torch.Tensor.addr(input0, input1, input2)
    # tmp_result= torch.Tensor.addmv(input1, input0, input2)
    return tmp_result
res = test()
# res1.backward()
# Enable the above line:
# addr returns: RuntimeError: expected scalar type ComplexDouble but found Double
# addmv returns: RuntimeError: Expected isFloatingType(grad.scalar_type()) || (input_is_complex == grad_is_complex) to be true, but got false.
```

### Error Results

When using `torch.Tensor.addr`, `res1.backward()` will return:
```
RuntimeError: expected scalar type ComplexDouble but found Double
```


When using `torch.Tensor.addmv`, `res1.backward()` will return:
```
RuntimeError: Expected isFloatingType(grad.scalar_type()) || (input_is_complex == grad_is_complex) to be true, but got false.
```

### Expected behavior

Perhaps it could handle this data inconsistency in the backend calculation like `torch.nn.functional.poisson_nll_loss` or `torch.nn.functional.l1_loss` mentioned in [#76785](https://github.com/pytorch/pytorch/issues/76785).
Or directly add the detection of the consistency of the input dtype in the forward process.



### Versions


<details>
  <summary>pytorch 1.13.1</summary>
  <pre><code>
  [pip3] numpy==1.22.3
  [pip3] torch==1.13.1
  [pip3] torchelastic==0.2.2
  [pip3] torchtext==0.14.1
  [pip3] torchvision==0.14.1
  [conda] blas                      1.0                         mkl  
  [conda] ffmpeg                    4.3                  hf484d3e_0    pytorch
  [conda] mkl                       2021.4.0           h06a4308_640  
  [conda] mkl-service               2.4.0           py310h7f8727e_0  
  [conda] mkl_fft                   1.3.1           py310hd6ae3a3_0  
  [conda] mkl_random                1.2.2           py310h00e6091_0  
  [conda] numpy                     1.22.3          py310hfa59a62_0  
  [conda] numpy-base                1.22.3          py310h9585f30_0  
  [conda] pytorch                   1.13.1          py3.10_cuda11.6_cudnn8.3.2_0    pytorch
  [conda] pytorch-cuda              11.6                 h867d48c_1    pytorch
  [conda] pytorch-mutex             1.0                        cuda    pytorch
  [conda] torchelastic              0.2.2                    pypi_0    pypi
  [conda] torchtext                 0.14.1                    py310    pytorch
  [conda] torchvision               0.14.1              py310_cu116    pytorch</code></pre>
</details>



cc @ezyang @albanD @zou3519 @gqchen @pearu @nikitaved @soulitzer @Lezcano @Varal7 @anjali411 @dylanbespalko @mruberry @nairbv @jianyuh @walterddr @IvanYashchuk @xwang233