cornell-zhang / hcl-dialect

HeteroCL-MLIR dialect for accelerator design
https://cornell-zhang.github.io/heterocl/index.html
Other
38 stars 17 forks source link

[Pass] Incorrect alloc operation movement from device to host #58

Closed chhzh123 closed 2 years ago

chhzh123 commented 2 years ago

In the original implementation, the alloc B operation will be moved from device to host, causing UNKNOWN_VALUE in the xcel program.

def test_move_outputs():
    hcl.init()
    A = hcl.placeholder((10, 32), "A")
    def kernel(A):
        B = hcl.compute(A.shape, lambda i, j: A[i, j] * 2, "B")
        hcl.update(B, lambda i, j: B[i, j] + 1, "update1")
        hcl.update(B, lambda i, j: B[i, j] * 2, "update2")
        return B

    target = hcl.Platform.aws_f1
    target.config(compiler="vivado_hls", mode="csim", project="test.prj")
    s = hcl.create_schedule([A], kernel)
    s.to(A, target.xcel)
    s.to(kernel.update1.B, target.host)

    mod = hcl.build(s, target)
chhzh123 commented 2 years ago

This is because hcl.update forces B to be used on both CPU and FPGA.