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

[Fix] Formatting and insertion point #488

Closed chhzh123 closed 1 year ago

chhzh123 commented 1 year ago

This PR fixes the failure in #486 (which is because the PR branch is not up-to-date and does not cover necessary CI formatting tests).

Also, it fixes the insertion point for GlobalOp. We should follow C/C++ convention that declare all the required variables before usage. For example, instead of

module {
  func.func @top(%arg0: memref<1x16x30x30xi32>) -> memref<1x16x30x30x!hcl.Fixed<26, 20>> attributes {itypes = "s", otypes = "_"} {
    ...
  }
  memref.global "private" constant @bn_weight : memref<16xi64> = dense<[...]>
  memref.global "private" constant @bn_bias : memref<16xi64> = dense<[...]>
}

We should do the following

module {
  memref.global "private" constant @bn_weight : memref<16xi64> = dense<[...]>
  memref.global "private" constant @bn_bias : memref<16xi64> = dense<[...]>
  func.func @top(%arg0: memref<1x16x30x30xi32>) -> memref<1x16x30x30x!hcl.Fixed<26, 20>> attributes {itypes = "s", otypes = "_"} {
    ...
  }
}

This would also simplify the backend HLS codegen.

zzzDavid commented 1 year ago

The GlobalOp insertion point change makes sense