cornell-zhang/hcl-dialect

Schedule creation error with hcl.if_ and struct field access in the condition

Closed this issue · 3 comments

def test_if_struct_access():
    hcl.init()

    def kernel():
        tag = hcl.scalar(0, "tag", dtype='uint32')

        stype = hcl.Struct({"x": hcl.UInt(8), "y": hcl.UInt(8)})
        xy = hcl.scalar(0x1234, "xy", dtype=stype).v

        with hcl.if_(xy.x==1):  # use of struct field access causes a scheduler error
            tag.v = 1

        r = hcl.compute((2,), lambda i: tag.v, dtype=hcl.UInt(32))
        return r
    s = hcl.create_schedule([], kernel)

The above code generates the following runtime error:

error: 'affine.load' op operation destroyed but still has uses
LLVM ERROR: operation destroyed but still has uses

Fixed by 7906b26

Added remove and profile mode for struct op visitors