Skip to content

Incorrect kernel for binaryOp(scalar, tensor) #1777

@IvanYashchuk

Description

@IvanYashchuk

🐛 Describe the bug

import torch
from torch._C._nvfuser import Fusion, FusionDefinition, DataType

# Construct and Define Fusion
fusion = Fusion()

with FusionDefinition(fusion) as fd :
    t0 = fd.define_tensor(0)
    fd.add_input(t0)
    c0 = fd.define_constant(1.5)
    t1 = fd.Ops.div(c0, t0)
    fd.add_output(t1)

fusion.print_ir()

Output:

Inputs:
  T0_g[ iS0{i0}, iS1{i2} ], float
Outputs:
  T1_g[ iS2{i0}, iS3{i2} ], float

%kernel_math {
T1_g[ iS2{i0}, iS3{i2} ]
   = T0_g[ iS0{i0}, iS1{i2} ] # this should be double(1.5)
   / T0_g[ iS0{i0}, iS1{i2} ];
}

The bug is on this line

BinaryOpType::op_type, v2, v2, TypePromotion::float_op_config); \

Versions

.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions