Repository: pytorch
Issue: [JIT] INTERNAL ASSERT FAILED `torch.mul` with boolean primitive constant
Labels: oncall: jit

### 🐛 Describe the bug

```python
import torch

def fn(x):  # OK ~ int,float,etc. primitive
    return torch.mul(x, 1)

traced = torch.jit.trace(fn, (torch.zeros((), dtype=torch.int),))


def fn(x):  # Error ~ bool primitive
    return torch.mul(x, True)

# eager: OK
torch.mul(torch.zeros((), dtype=torch.bool), True)
# jit trace
traced = torch.jit.trace(fn, (torch.zeros((), dtype=torch.bool),))
```

<details><summary><b>Log</b> <i>[click to expand]</i></summary>
<div>

```
"""
Traceback (most recent call last):
  File "/home/jiawei/miniconda3/lib/python3.9/site-packages/torch/jit/_trace.py", line 460, in run_mod_and_filter_tensor_outputs
    outs = wrap_retval(mod(*_clone_inputs(inputs)))
RuntimeError: 0 INTERNAL ASSERT FAILED at "../torch/csrc/jit/ir/alias_analysis.cpp":608, please report a bug to PyTorch. We don't have an op for aten::mul but it isn't a special case.  Argument types: Tensor, bool, 

Candidates:
        aten::mul.Tensor(Tensor self, Tensor other) -> Tensor
        aten::mul.Scalar(Tensor self, Scalar other) -> Tensor
        aten::mul.out(Tensor self, Tensor other, *, Tensor(a!) out) -> Tensor(a!)
        aten::mul.Scalar_out(Tensor self, Scalar other, *, Tensor(a!) out) -> Tensor(a!)
        aten::mul.left_t(t[] l, int n) -> t[]
        aten::mul.right_(int n, t[] l) -> t[]
        aten::mul.int(int a, int b) -> int
        aten::mul.complex(complex a, complex b) -> complex
        aten::mul.float(float a, float b) -> float
        aten::mul.int_complex(int a, complex b) -> complex
        aten::mul.complex_int(complex a, int b) -> complex
        aten::mul.float_complex(float a, complex b) -> complex
        aten::mul.complex_float(complex a, float b) -> complex
        aten::mul.int_float(int a, float b) -> float
        aten::mul.float_int(float a, int b) -> float
        aten::mul(Scalar a, Scalar b) -> Scalar

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/test.py", line 18, in <module>
    traced = torch.jit.trace(fn, (torch.zeros((), dtype=torch.bool),))
  File "/home/jiawei/miniconda3/lib/python3.9/site-packages/torch/jit/_trace.py", line 881, in trace
    _check_trace(
  File "/home/jiawei/miniconda3/lib/python3.9/site-packages/torch/autograd/grad_mode.py", line 34, in decorate_context
    return func(*args, **kwargs)
  File "/home/jiawei/miniconda3/lib/python3.9/site-packages/torch/jit/_trace.py", line 551, in _check_trace
    traced_outs = run_mod_and_filter_tensor_outputs(traced_func, inputs, "trace")
  File "/home/jiawei/miniconda3/lib/python3.9/site-packages/torch/jit/_trace.py", line 466, in run_mod_and_filter_tensor_outputs
    raise TracingCheckError(
torch.jit._trace.TracingCheckError: Tracing failed sanity checks!
encountered an exception while running the trace with test inputs.
Exception:
        0 INTERNAL ASSERT FAILED at "../torch/csrc/jit/ir/alias_analysis.cpp":608, please report a bug to PyTorch. We don't have an op for aten::mul but it isn't a special case.  Argument types: Tensor, bool, 

        Candidates:
                aten::mul.Tensor(Tensor self, Tensor other) -> Tensor
                aten::mul.Scalar(Tensor self, Scalar other) -> Tensor
                aten::mul.out(Tensor self, Tensor other, *, Tensor(a!) out) -> Tensor(a!)
                aten::mul.Scalar_out(Tensor self, Scalar other, *, Tensor(a!) out) -> Tensor(a!)
                aten::mul.left_t(t[] l, int n) -> t[]
                aten::mul.right_(int n, t[] l) -> t[]
                aten::mul.int(int a, int b) -> int
                aten::mul.complex(complex a, complex b) -> complex
                aten::mul.float(float a, float b) -> float
                aten::mul.int_complex(int a, complex b) -> complex
                aten::mul.complex_int(complex a, int b) -> complex
                aten::mul.float_complex(float a, complex b) -> complex
                aten::mul.complex_float(complex a, float b) -> complex
                aten::mul.int_float(int a, float b) -> float
                aten::mul.float_int(float a, int b) -> float
                aten::mul(Scalar a, Scalar b) -> Scalar
"""
```

</div>
</details>

`torch.mul(x, ${CONSTANT})` works when `CONSTANT` is `int/float/...` but failed at `bool`. The torch eager mode also supports using boolean as constant operand of `torch.mul`. We should fix this case to ensure the code compatibility from eager to jit.


### Versions

<details><summary><b>Env </b> <i>[click to expand]</i></summary>
<div>

```python
"""
Collecting environment information...
PyTorch version: 1.14.0.dev20221202+cu117
Is debug build: False
CUDA used to build PyTorch: 11.7
ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.1 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0
Clang version: Could not collect
CMake version: version 3.25.0
Libc version: glibc-2.35

Python version: 3.9.12 (main, Apr  5 2022, 06:56:58)  [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.15.0-56-generic-x86_64-with-glibc2.35
Is CUDA available: True
CUDA runtime version: 11.6.124
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: 
GPU 0: NVIDIA GeForce RTX 3090
GPU 1: NVIDIA GeForce RTX 3090
GPU 2: NVIDIA GeForce RTX 3090

Nvidia driver version: 515.86.01
cuDNN version: Probably one of the following:
/usr/lib/x86_64-linux-gnu/libcudnn.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv_infer.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_adv_train.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_infer.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_cnn_train.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops_infer.so.8.4.1
/usr/lib/x86_64-linux-gnu/libcudnn_ops_train.so.8.4.1
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.23.3
[pip3] onnx2torch==1.5.3
[pip3] torch==1.14.0.dev20221202+cu117
[pip3] torchaudio==0.14.0.dev20221203+cu117
[pip3] torchtriton==2.0.0+0d7e753227
[pip3] torchvision==0.15.0.dev20221203+cpu
[conda] numpy                     1.23.3                   pypi_0    pypi
[conda] onnx2torch                1.5.3                    pypi_0    pypi
[conda] torch                     1.14.0.dev20221202+cu117          pypi_0    pypi
[conda] torchaudio                0.14.0.dev20221203+cu117          pypi_0    pypi
[conda] torchtriton               2.0.0+0d7e753227          pypi_0    pypi
[conda] torchvision               0.15.0.dev20221203+cpu          pypi_0    pypi
"""
```

</div>
</details>

cc @EikanWang @jgong5 @wenzhe-nrv @sanchitintel