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

Support static variables inside HCL module #309

Open hecmay opened 3 years ago

hecmay commented 3 years ago

Now we have support for chained .to() and explicit unrolling with PR #256. To realize a weight stationary systolic array in HLS, we should also consider supporting static variable inside a HCL module (i.e. for initializing the updating the weight).

This should not be hard to support technically -- we can add a new attribute to the Allocate IR, and print the static keyword when the attribute is present. But I am still thinking about how we should expose this feature to users. This is one possible interface.

# declare the tensor A to be static 
A = hcl.compute((size, ), lambda, static=True)

# update the static variable in initialization
with hcl.if_():
    hcl.update(A, lambda)

Or should we design the interface in a decoupled way?