KEMBAR78
index.Tensor_out doesn't properly handle dtype conversions · Issue #107698 · pytorch/pytorch · GitHub
Skip to content

index.Tensor_out doesn't properly handle dtype conversions #107698

@manuelcandales

Description

@manuelcandales

🐛 Describe the bug

import torch

input = torch.tensor([[1, 2], [3, 4]], dtype=torch.int)
indices = [torch.tensor([[True, False], [False, True]], dtype=torch.bool)]

# Both should return tensor [1, 4], but it seems index doesn't properly handle dtype conversions
print(torch.ops.aten.index.Tensor_out(input, indices, out=torch.tensor([0, 0], dtype=torch.int)))
print(torch.ops.aten.index.Tensor_out(input, indices, out=torch.tensor([0, 0], dtype=torch.long)))

Result:

tensor([1, 4], dtype=torch.int32)
tensor([8589934593,          4])

Versions

Collecting environment information...
PyTorch version: 2.0.1
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 13.5 (arm64)
GCC version: Could not collect
Clang version: 14.0.0 (clang-1400.0.29.202)
CMake version: Could not collect
Libc version: N/A

Python version: 3.9.6 (default, Oct 18 2022, 12:41:40) [Clang 14.0.0 (clang-1400.0.29.202)] (64-bit runtime)
Python platform: macOS-13.5-arm64-arm-64bit
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:
Apple M1 Pro

Versions of relevant libraries:
[pip3] numpy==1.24.3
[pip3] torch==2.0.1
[conda] Could not collect

cc @ezyang @gchanan @zou3519 @malfet

Metadata

Metadata

Assignees

Labels

high prioritymodule: advanced indexingRelated to x[i] = y, index functionsmodule: correctness (silent)issue that returns an incorrect result silentlymodule: error checkingBugs related to incorrect/lacking error checkingtriagedThis issue has been looked at a team member, and triaged and prioritized into an appropriate module

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions