Skip to content

[TensorIterator] bug when performing inter-scalar ops on the GPU #11795

@fmassa

Description

@fmassa

When performing operations between scalar tensors of different types, type promotion happens in TensorIterator. But it seems that the results of inter-type operations are not correct when performing operations on the GPU.

The following code gives unexpected results on the GPU. CPU works fine

import torch

torch.__version__
# '1.0.0a0+91b6458', master from today

a = torch.tensor(1.5, device='cuda')  # float tensor
b = torch.tensor(1, device='cuda')  # int64 tensor
print(a * b)
# tensor(2.8026e-45, device='cuda:0')

a = torch.tensor(1.5, device='cuda')  # float tensor
b = torch.tensor(True, device='cuda') # uint8 tensor
print(a * b)
# tensor(2.8026e-45, device='cuda:0')
print(a + b)
# tensor(1.5000, device='cuda:0')
print(a - b)
# tensor(1.5000, device='cuda:0')

cc @colesbury

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions