Operating on boolean torch tensor and numpy array casts to unit8
#77962
Labels
module: boolean tensor
module: numpy
Related to numpy support, and also numpy compatibility of our operators
module: type promotion
Related to semantics of type promotion
triaged
This issue has been looked at a team member, and triaged and prioritized into an appropriate module
馃悰 Describe the bug
Sometimes one accidentally mixes
torch
andnumpy
arrays in the code. When this happens,numpy
generally raisesTypeError
, whiletorch
usually handles these situations gracefully. However, for boolean operationstorch
recasts touint8
, which leads to unexpected error messages down the roadoutputs
tensor(1, dtype=torch.uint8)
withdtype
unit8
. Expected output would betensor(True)
with boolean dtype.Versions
PyTorch version: 1.11.0+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A
OS: Ubuntu 20.04.4 LTS (x86_64)
GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: glibc-2.31
Python version: 3.8.12 (default, Oct 12 2021, 13:49:34) [GCC 7.5.0] (64-bit runtime)
Python platform: Linux-5.13.0-41-generic-x86_64-with-glibc2.17
Is CUDA available: False
CUDA runtime version: No CUDA
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
Versions of relevant libraries:
[pip3] mypy==0.941
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.22.3
[pip3] torch==1.11.0
[conda] numpy 1.22.3 pypi_0 pypi
[conda] torch 1.11.0 pypi_0 pypi
cc @mruberry @rgommers @nairbv
The text was updated successfully, but these errors were encountered: