Skip to content

Issue with broadcasting (3, 1) and (3,) tensors #1788

@IvanYashchuk

Description

@IvanYashchuk

🐛 Describe the bug

Is this a bug in the nvFuser or the code below is invalid? I think the code is valid, I translated the trace of torch._refs.add to nvFuser Python API calls. There's no error with ATen execution.

import torch

from torch._C._nvfuser import Fusion, FusionDefinition

# Construct and Define Fusion
fusion = Fusion()

with FusionDefinition(fusion) as fd :
    t0 = fd.define_tensor(2)
    t1 = fd.define_tensor(1)

    fd.add_input(t0)
    fd.add_input(t1)

    t0_b = fd.Ops.broadcast_in_dim(t0, [3, 3], [0, 1])
    t1_b = fd.Ops.broadcast_in_dim(t1, [3, 3], [1])
    t2 = fd.Ops.add(t0_b, t1_b)

    fd.add_output(t2)

fusion.print_ir()

# Execute Fusion
input1 = torch.ones(3, 1, device='cuda')
input2 = torch.ones(3, device='cuda')

fusion.execute([input1, input2])

fusion.execute call raises

RuntimeError: Attempting to bind T0.size[1] to 3but it's already set to 1

Versions

.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions