Repository: pytorch
Issue: operator benchmark diag test cuda problem
Labels: triaged,op-bench,module: benchmark

### 🐛 Describe the bug

when run diag test in operator benchmark, got device problem with cuda, error info is below

```
(py310_pt20) hzeng@dell:~/prj/pytorch/benchmarks/operator_benchmark$ python -m benchmark_all_test --operators diag --omp-num-threads 1 --mkl-num-threads 1 --device cuda --tag_filter all
# ----------------------------------------
# PyTorch/Caffe2 Operator Micro-benchmarks
# ----------------------------------------
# Tag : all

# Benchmarking PyTorch: diag
Traceback (most recent call last):
  File "/home/hzeng/miniconda3/envs/py310_pt20/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/home/hzeng/miniconda3/envs/py310_pt20/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/home/hzeng/prj/pytorch/benchmarks/operator_benchmark/benchmark_all_test.py", line 9, in <module>
    op_bench.benchmark_runner.main()
  File "/home/hzeng/prj/pytorch/benchmarks/operator_benchmark/benchmark_runner.py", line 168, in main
    benchmark_core.BenchmarkRunner(args).run()
  File "/home/hzeng/prj/pytorch/benchmarks/operator_benchmark/benchmark_core.py", line 430, in run
    launch_func(
  File "/home/hzeng/prj/pytorch/benchmarks/operator_benchmark/benchmark_core.py", line 276, in _launch_forward
    forward_time = timeit.timeit(
  File "/home/hzeng/miniconda3/envs/py310_pt20/lib/python3.10/timeit.py", line 234, in timeit
    return Timer(stmt, setup, timer, globals).timeit(number)
  File "/home/hzeng/miniconda3/envs/py310_pt20/lib/python3.10/timeit.py", line 178, in timeit
    timing = self.inner(it, self.timer)
  File "<timeit-src>", line 6, in inner
  File "/home/hzeng/prj/pytorch/benchmarks/operator_benchmark/benchmark_pytorch.py", line 160, in run_forward
    self.output = self.op_bench.forward_impl()
  File "/home/hzeng/prj/pytorch/benchmarks/operator_benchmark/benchmark_pytorch.py", line 66, in forward_impl
    return self.forward(*self.get_inputs())
  File "/home/hzeng/prj/pytorch/benchmarks/operator_benchmark/pt/diag_test.py", line 40, in forward
    return torch.diag(input, diagonal=diagonal, out=out_tensor)
RuntimeError: Expected out tensor to have device cuda:0, but got cpu instead
```

and caused by cpu data used by out_tensor, to fix this , make out_tensor device same as input, like this(change file pt/diag_test.py)

```
def forward(self, input, diagonal: int, out: bool, out_tensor):
        out_tensor = out_tensor.to(input.device)
        if out:
            return torch.diag(input, diagonal=diagonal, out=out_tensor)
        else:
            return torch.diag(input, diagonal=diagonal)
```

### Versions

PyTorch version: 2.0.0+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 20.04.6 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.3) 9.4.0
Clang version: 10.0.0-4ubuntu1
CMake version: version 3.28.1
Libc version: glibc-2.31

Python version: 3.10.13 (main, Sep 11 2023, 13:44:35) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-5.15.146.1-microsoft-standard-WSL2-x86_64-with-glibc2.31
Is CUDA available: True
CUDA runtime version: 12.3.103
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3090
Nvidia driver version: 552.41
cuDNN version: Could not collect
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Byte Order:                         Little Endian
Address sizes:                      46 bits physical, 48 bits virtual
CPU(s):                             24
On-line CPU(s) list:                0-23
Thread(s) per core:                 2
Core(s) per socket:                 12
Socket(s):                          1
Vendor ID:                          GenuineIntel
CPU family:                         6
Model:                              183
Model name:                         13th Gen Intel(R) Core(TM) i7-13700K
Stepping:                           1
CPU MHz:                            3417.598
BogoMIPS:                           6835.19
Virtualization:                     VT-x
Hypervisor vendor:                  Microsoft
Virtualization type:                full
L1d cache:                          576 KiB
L1i cache:                          384 KiB
L2 cache:                           24 MiB
L3 cache:                           30 MiB
Vulnerability Gather data sampling: Not affected
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Mitigation; Enhanced IBRS
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl and seccomp
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves avx_vnni umip waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] numpy==1.26.2
[pip3] torch==2.0.0
[pip3] torchaudio==2.0.1
[pip3] torchdata==0.6.0
[pip3] torchtext==0.15.1
[pip3] torchvision==0.15.1
[pip3] triton==2.0.0
[conda] numpy                     1.26.2                   pypi_0    pypi
[conda] torch                     2.0.0                    pypi_0    pypi
[conda] torchaudio                2.0.1                    pypi_0    pypi
[conda] torchdata                 0.6.0                    pypi_0    pypi
[conda] torchtext                 0.15.1                   pypi_0    pypi
[conda] torchvision               0.15.1                   pypi_0    pypi
[conda] triton                    2.0.0                    pypi_0    pypi