Skip to content

Multiplication of a float tensor and a bool tensor produces a bool tensor on PyTorch #686

Open
@kazssym

Description

@kazssym

Multiplying a float tensor and a bool tensor on DML produces a bool tensor which is expected to be a float tensor as on CPU.

import torch
import torch_directml

dml = torch_directml.device()

t1cpu = torch.Tensor([0, 1])
t1dml = t1cpu.to(dml)

t2cpu = t1cpu > 0
t2dml = t1dml > 0

t1cpu *= t2cpu
t1dml *= t2dml

print(t1cpu)
print(t1dml)

Output:

tensor([0., 1.])
tensor([False,  True], device='privateuseone:0')

Version:

torch                2.4.1
torch-directml       0.2.5.dev240914

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions