Repository: pytorch
Issue: Dynamo infers different return type vs. eager for `torch.ops.aten`
Labels: good first issue,triaged,oncall: pt2,module: decompositions

### 🐛 Describe the bug

```python
import torch
from torch._dynamo.backends.common import aot_autograd
from torch._functorch.aot_autograd import make_boxed_compiler
import torch._dynamo as dynamo


@make_boxed_compiler
def my_aot_autograd_backend(gm: torch.fx.GraphModule, _example_inputs):
    last_node = list(gm.graph.nodes)[-2]
    print("dynamo return dtype", last_node.meta["val"].dtype)
    return gm


my_backend = aot_autograd(fw_compiler=my_aot_autograd_backend)


def compile(model, example_args):
    with torch.no_grad():
        torch._dynamo.reset()
        dynamo.optimize(my_backend, nopython=True)(model)(*example_args)


def run(model, example_args):
    print(model.__class__.__name__)
    print(
        f"eager return dtype",
        model.forward(*example_args).dtype,
    )
    compile(model, example_args)
    print()


class BaddbmmDifferentDtypesModule(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, input, batch1, batch2):
        return torch.ops.aten.baddbmm(input, batch1, batch2)


run(
    BaddbmmDifferentDtypesModule(),
    (
        torch.randint(size=(3, 4, 5), low=0, high=10),
        torch.rand(3, 4, 6),
        torch.rand(3, 6, 5),
    ),
)


class FullModuleInt3D(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self):
        return torch.ops.aten.full([2, 3, 4], 5)


run(FullModuleInt3D(), ())


class ThresholdBackward1dIntModule(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, grad, input):
        return torch.ops.aten.threshold_backward(grad, input, 1)


run(
    ThresholdBackward1dIntModule(),
    (torch.randint(0, 10, (4,)), torch.randint(0, 8, (4,))),
)


class ThresholdBackward2dIntModule(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, grad, input):
        return torch.ops.aten.threshold_backward(grad, input, 0.5)


run(
    ThresholdBackward2dIntModule(),
    (torch.randint(0, 10, (4, 5)), torch.randint(0, 8, (4, 5))),
)


class ThresholdBackward3dIntModule(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self, grad, input):
        return torch.ops.aten.threshold_backward(grad, input, 1)


run(
    ThresholdBackward2dIntModule(),
    (torch.randint(0, 10, (4, 5, 6)), torch.randint(0, 8, (4, 5, 6))),
)
```

cc @ezyang @soumith @msaroufim @wconstab @ngimel @bdhirsh @anijain2305 @SherlockNoMad @powderluv, @ramiro050

### Versions

```
Collecting environment information...
PyTorch version: 2.1.0.dev20230428+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Clang version: 14.0.6
CMake version: version 3.26.3
Libc version: glibc-2.35

Python version: 3.10.10 | packaged by conda-forge | (main, Mar 24 2023, 20:08:06) [GCC 11.3.0] (64-bit runtime)
Python platform: Linux-5.19.0-41-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.7.99
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3080
Nvidia driver version: 515.65.01
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
Address sizes:                   48 bits physical, 48 bits virtual
Byte Order:                      Little Endian
CPU(s):                          32
On-line CPU(s) list:             0-31
Vendor ID:                       AuthenticAMD
Model name:                      AMD Ryzen 9 5950X 16-Core Processor
CPU family:                      25
Model:                           33
Thread(s) per core:              2
Core(s) per socket:              16
Socket(s):                       1
Stepping:                        0
Frequency boost:                 enabled
CPU max MHz:                     5083.3979
CPU min MHz:                     2200.0000
BogoMIPS:                        6787.52
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 constant_tsc rep_good nopl nonstop_tsc cpuid extd_apicid aperfmperf rapl pni pclmulqdq monitor ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand lahf_lm cmp_legacy svm extapic cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw ibs skinit wdt tce topoext perfctr_core perfctr_nb bpext perfctr_llc mwaitx cpb cat_l3 cdp_l3 hw_pstate ssbd mba ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 invpcid cqm rdt_a rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local clzero irperf xsaveerptr rdpru wbnoinvd arat npt lbrv svm_lock nrip_save tsc_scale vmcb_clean flushbyasid decodeassists pausefilter pfthreshold avic v_vmsave_vmload vgif v_spec_ctrl umip pku ospke vaes vpclmulqdq rdpid overflow_recov succor smca
Virtualization:                  AMD-V
L1d cache:                       512 KiB (16 instances)
L1i cache:                       512 KiB (16 instances)
L2 cache:                        8 MiB (16 instances)
L3 cache:                        64 MiB (2 instances)
NUMA node(s):                    1
NUMA node0 CPU(s):               0-31
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:          Not affected
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:        Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP always-on, RSB filling, PBRSB-eIBRS Not affected
Vulnerability Srbds:             Not affected
Vulnerability Tsx async abort:   Not affected

Versions of relevant libraries:
[pip3] numpy==1.24.3
[pip3] pytorch-triton==2.1.0+7d1a95b046
[pip3] torch==2.1.0.dev20230428+cu117
[pip3] torchaudio==2.0.0.dev20230313+cu117
[pip3] torchvision==0.16.0.dev20230428+cu117
[pip3] triton==2.0.0
[conda] numpy                     1.24.3                   pypi_0    pypi
[conda] pytorch-triton            2.1.0+7d1a95b046          pypi_0    pypi
[conda] torch                     2.1.0.dev20230428+cu117          pypi_0    pypi
[conda] torchaudio                2.0.0.dev20230313+cu117          pypi_0    pypi
[conda] torchvision               0.16.0.dev20230428+cu117          pypi_0    pypi
[conda] triton                    2.0.0                    pypi_0    pypi
```