Repository: pytorch
Issue: JIT tracing check fails with boolean tensor modifications
Labels: triage review,oncall: jit,actionable

## 🐛 Bug

Tracing code that modifies a boolean tensor fails with TracingCheckError. Tracing works only with `torch.jit.trace(..., check_trace=False)`.

## To Reproduce

Small repro case:

```
import torch
import torch.nn


class Model(torch.nn.Module):
    def __init__(self):
        super().__init__()

    def forward(self):
        mask = torch.zeros(5, dtype=torch.bool)
        mask[1] = True
        return mask


model = Model()

# fails with torch.jit.TracingCheckError
traced_model = torch.jit.trace(model, ())

# works
#traced_model = torch.jit.trace(model, (), check_trace=False)
```

Running `python bool_trace.py` fails with:

```
Traceback (most recent call last):
  File "bool_trace.py", line 17, in <module>
    traced_model = torch.jit.trace(model, ())
  File "/home/jarno/miniconda3/envs/scratch/lib/python3.6/site-packages/torch/jit/__init__.py", line 882, in trace
    check_tolerance, _force_outplace, _module_class)
  File "/home/jarno/miniconda3/envs/scratch/lib/python3.6/site-packages/torch/jit/__init__.py", line 1044, in trace_module
    check_tolerance, _force_outplace, True, _module_class)
  File "/home/jarno/miniconda3/envs/scratch/lib/python3.6/site-packages/torch/autograd/grad_mode.py", line 49, in decorate_no_grad
    return func(*args, **kwargs)
  File "/home/jarno/miniconda3/envs/scratch/lib/python3.6/site-packages/torch/jit/__init__.py", line 685, in _check_trace
    raise TracingCheckError(*diag_info)
torch.jit.TracingCheckError: Tracing failed sanity checks!
ERROR: Tensor-valued Constant nodes differed in value across invocations. This often indicates that the tracer has encountered untraceable code.
	Node:
		%11 : Tensor = prim::Constant[value={1}]() # bool_trace.py:12:0
	Source Location:
		bool_trace.py(12): forward
		/home/jarno/miniconda3/envs/scratch/lib/python3.6/site-packages/torch/nn/modules/module.py(516): _slow_forward
		/home/jarno/miniconda3/envs/scratch/lib/python3.6/site-packages/torch/nn/modules/module.py(530): __call__
		/home/jarno/miniconda3/envs/scratch/lib/python3.6/site-packages/torch/jit/__init__.py(1034): trace_module
		/home/jarno/miniconda3/envs/scratch/lib/python3.6/site-packages/torch/jit/__init__.py(882): trace
		bool_trace.py(17): <module>
	Comparison exception: 	Subtraction, the `-` operator, with two bool tensors is not supported. Use the `^` or `logical_xor()` operator instead.
```


## Expected behavior

tracing should work equally well with `check_trace=True` as `=False`

## Environment

```
Collecting environment information...
PyTorch version: 1.4.0
Is debug build: No
CUDA used to build PyTorch: 10.1

OS: Ubuntu 18.04.4 LTS
GCC version: (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0
CMake version: version 3.10.2

Python version: 3.6
Is CUDA available: No
CUDA runtime version: No CUDA
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA

Versions of relevant libraries:
[pip] numpy==1.18.1
[pip] torch==1.4.0
[conda] blas                      1.0                         mkl  
[conda] mkl                       2020.0                      166  
[conda] mkl-service               2.3.0            py36he904b0f_0  
[conda] mkl_fft                   1.0.15           py36ha843d7b_0  
[conda] mkl_random                1.1.0            py36hd6b4f25_0  
[conda] pytorch                   1.4.0           py3.6_cuda10.1.243_cudnn7.6.3_0    pytorch
```


cc @suo