cornell-zhang/heterocl

Create compute or hlib APIs to generate non-inlined HW modules

Closed this issue · 2 comments

HCL compute or hlib APIs generate nested for-loops in the function body by default.

# input python code
A = hcl.compute((10,), lambda x: x, "A")
B = hlib.conv2d_nchw(input, weight, padding=[1,1], stride=[1,1])
// generated HLS code
allocate A;
for (i, 10)
    A[i] = i;

for (n, N)
    for (c, C)
        for (h, H)
            for(w, W)
                for (r, R)
                    for (c, C)
                        v += weight[r, c] * input[y, x]

There should be a mode to create function calls for certain compute or hlib functions, like

A = hcl.compute((10,), lambda x: x, "A", module=True)
void k(int * A) {
    for (i, 10)
        A[i] = i;
}
allocate A;
k(A);

Should help solve this issue #278

Closed. The function outlining should be realized in a decoupled way, instead of adding an option in the compute API. @zzzDavid will propose a PR to support this feature.