-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using hcl.scalar with struct dtype fails #133
Comments
There are three things to be supported/fixed for such cases:
|
The error |
The UInt issue is fixed by 025e533. When constructing the AST, the ExprOp nodes retains the sign information, i.e. an unsigned integer type is represented as |
Up to this commit 0f1802c, passing tuple and integer to This particular test has passed and is added to the test suite here: However, |
The following kernel code also generates an error:
In this case, xy is NOT used but somehow the hcl.scalar w/ struct dtype is causing the following error:
If hcl.scalar used a non-struct dtype (e.g., uint32), no runtime error is generated. |
This issue is caused by how structs are lowered in the Conversion pass. The current struct lowering looks at the where the struct is used, and then get the field value from the struct construct op. So when there's no usage, the struct doesn't gets lowered (i.e. folded). I'll add DCE to resolve this issue. |
This is more interesting than I thought, a simple DCE won't suffice: module {
func.func @top() -> memref<2xi32> attributes {itypes = "", otypes = "u"} {
%0 = memref.alloc() {name = "foo"} : memref<1x!hcl.struct<i8, i8>>
%c18_i8 = arith.constant {unsigned} 18 : i8
%c0_i8 = arith.constant {unsigned} 0 : i8
%1 = hcl.struct_construct(%c18_i8, %c0_i8) : i8, i8 -> <i8, i8>
affine.store %1, %0[0] {to = "foo"} : memref<1x!hcl.struct<i8, i8>>
%2 = memref.alloc() {name = "compute_0", unsigned} : memref<2xi32>
affine.for %arg0 = 0 to 2 {
%c0_i32 = arith.constant {unsigned} 0 : i32
affine.store %c0_i32, %2[%arg0] {to = "compute_0"} : memref<2xi32>
} {loop_name = "i", op_name = "compute_0"}
return %2 : memref<2xi32>
}
} The |
I think we should add a pass to remove all memrefs allocated, initialized, but never used (loaded from). |
I agree that allocated/initialized but unused memrefs should be removed -- shouldn't this be part of DCE already? |
I think MLIR should have DCE passes available for removing unused memrefs. The runtime error of |
Added test case for unused struct tensor: |
Closing the thread as the issue has been resolved |
The following code passes with the main branch:
With hcl-mlir, I get the following error:
File "/home/jcasas/dprive/heterocl_mlir/hcl-dialect-prototype/build/tools/hcl/python_packages/hcl_core/hcl_mlir/build_ir.py", line 901, in build
raise DTypeError(
hcl_mlir.exceptions.DTypeError: [Data Type] Type error: unrecognized type: !hcl.struct<ui8, ui8>
The text was updated successfully, but these errors were encountered: