Repository: pytorch
Issue: Cannot invoke prims.sum with output_dtype
Labels: triaged,module: primTorch

### 🐛 Describe the bug

Running
```python
import torch
import traceback
import sys

a = torch.zeros([3])

# Fine
torch.ops.prims.sum(a, dims=[0])

print("Trying with output_dtype keyword arg", file=sys.stderr)
"""
Prints
TypeError: sum() received an invalid combination of arguments - got (Tensor, list, output_dtype=torch.dtype), but expected one of:
 * (Tensor input, *, torch.dtype dtype)
      didn't match because some of the keywords were incorrect: output_dtype
 * (Tensor input, tuple of ints dim, bool keepdim, *, torch.dtype dtype, Tensor out)
 * (Tensor input, tuple of names dim, bool keepdim, *, torch.dtype dtype, Tensor out)
"""
try:
    torch.ops.prims.sum(a, dims=[0], output_dtype=torch.float64)
except:
    traceback.print_exc()
    pass

print("Trying with dtype keyword", file=sys.stderr)
# RuntimeError: Unknown keyword argument 'dtype' for operator 'prims::sum'. Schema: prims::sum(Tensor inp, int[]? dims, *, ScalarType? output_dtype=None) -> Tensor
try:
    torch.ops.prims.sum(a, dims=[0], dtype=torch.float64)
except:
    traceback.print_exc()
    pass


print("Trying with positional argument", file=sys.stderr)
# RuntimeError: prims::sum() takes 2 positional argument(s) but 3 was/were given.  Declaration: prims::sum(Tensor inp, int[]? dims, *, ScalarType? output_dtype=None) -> Tensor
try:
    torch.ops.prims.sum(a, [0], torch.float64)
except:
    traceback.print_exc()
    pass
```
fails all way of providing an output dtype to the prims.sum operation.

### Versions

Collecting environment information...
PyTorch version: 2.1.0.dev20230526+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
Clang version: 15.0.7
CMake version: version 3.26.3
Libc version: glibc-2.35

Python version: 3.10.6 (main, Mar 10 2023, 10:55:28) [GCC 11.3.0] (64-bit runtime)
Python platform: Linux-4.15.0-166-generic-x86_64-with-glibc2.35
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
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
Address sizes:                   48 bits physical, 48 bits virtual
Byte Order:                      Little Endian
CPU(s):                          16
On-line CPU(s) list:             0-15
Vendor ID:                       AuthenticAMD
Model name:                      AMD EPYC Processor
CPU family:                      23
Model:                           1
Thread(s) per core:              1
Core(s) per socket:              8
Socket(s):                       2
Stepping:                        2
BogoMIPS:                        5988.74
Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm rep_good nopl xtopology cpuid extd_apicid tsc_known_freq pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext ssbd ibpb vmmcall fsgsbase bmi1 avx2 smep bmi2 rdseed adx smap clflushopt sha_ni xsaveopt xsavec xgetbv1 virt_ssbd arat
Hypervisor vendor:               KVM
Virtualization type:             full
L1d cache:                       512 KiB (16 instances)
L1i cache:                       1 MiB (16 instances)
L2 cache:                        8 MiB (16 instances)
L3 cache:                        16 MiB (2 instances)
NUMA node(s):                    1
NUMA node0 CPU(s):               0-15
Vulnerability Itlb multihit:     Not affected
Vulnerability L1tf:              Not affected
Vulnerability Mds:               Not affected
Vulnerability Meltdown:          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; Full AMD retpoline, IBPB conditional, STIBP disabled, RSB filling
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected

Versions of relevant libraries:
[pip3] numpy==1.24.3
[pip3] pytorch-quantization==2.1.2
[pip3] torch==2.1.0.dev20230526+cpu
[pip3] torchvision==0.16.0.dev20230526+cpu
[conda] Could not collect

cc @ezyang @mruberry @ngimel @Lezcano @peterbell10