cornell-zhang / heterocl

HeteroCL: A Multi-Paradigm Programming Infrastructure for Software-Defined Heterogeneous Computing
https://cornell-zhang.github.io/heterocl/
Apache License 2.0
322 stars 92 forks source link

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

Closed hecmay closed 3 years ago

hecmay commented 4 years ago

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);
hecmay commented 4 years ago

Should help solve this issue #278

hecmay commented 3 years ago

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.