-
Notifications
You must be signed in to change notification settings - Fork 310
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
[Calyx] constant op #7770
[Calyx] constant op #7770
Conversation
Hi @rachitnigam @andrewb1999 @cgyurgyik , I'm trying to support the feature we discussed in here. When I'm running example: module {
func.func @main() -> i32 {
%0 = calyx.constant {value=4.2 : f32} : i32
return %0 : i32
}
} it tells me: calyx-const.mlir:4:42: error: expected attribute value
%0 = calyx.constant {value=4.2 : f32} : i32
^ so then I changed to: %0 = "calyx.constant"() <{value=4.2 : f32}> : () -> i32 it again complains: calyx-const.mlir:4:10: error: 'calyx.constant' op requires string attribute 'sym_name'
%0 = "calyx.constant"() <{value=4.2 : f32}> : () -> i32
^
calyx-const.mlir:4:10: note: see current operation: %0 = "calyx.constant"() <{value = 4.200000e+00 : f32}> : () -> i3 and then I changed to: %0 = "calyx.constant"() {sym_name="cst_0", value=4.2 : f32} : () -> i32 it complains: calyx-const.mlir:4:10: error: 'calyx.constant' op symbol's parent must have the SymbolTable trait
%0 = "calyx.constant"() {sym_name="cst_0", value=4.2 : f32} : () -> i32
^
calyx-const.mlir:4:10: note: see current operation: %0 = "calyx.constant"() <{value = 4.200000e+00 : f32}> {sym_name = "cst_0"} : () -> i32 Any idea how to fix it? |
I think your assembly format is wrong. I also think you shouldn't use
Also we need to remove the FirstAttrDerivedResultType property from the operation because the output type no longer necessarily matches the attribute type. |
I see, thanks! Is error: 'attr-dict' directive not found in custom assembly format
$sym_name ` ` `<` $value `>` `:` qualified(type($out))
^
Included from /scratch/jiahan/circt/include/circt/Dialect/Calyx/Calyx.td:95: My
any obvious mistake? |
Yeah my bad I forgot to add that to the format. Go ahead and add it right before the ':' |
No worries and thanks! Now I have:
but it complains: calyx-const.mlir:3:10: error: 'calyx.constant' op symbol's parent must have the SymbolTable trait
%0 = calyx.constant @cst <4.2 : f32> : i32
^
calyx-const.mlir:3:10: note: see current operation: %0 = "calyx.constant"() <{sym_name = "cst", value = 4.200000e+00 : f32}> : () -> i32 I mean my example is: module {
func.func @main() -> i32 {
%0 = calyx.constant @cst <4.2 : f32> : i32
return %0 : i32
}
} and |
Can you push what you have currently so I can take a closer look? |
Sure, just pushed, thank you! |
As can be seen here the func op does not have the I think you can simply switch to testing with a |
Indeed, I always assumed that it does...
I see, makes sense. Thanks!
Sounds good! |
2871ae5
to
0cf7a56
Compare
…ttribute, while the type is always unsigned integer. Make the corresponding change for addf operator so that they also take integer inputs and produce integer results; make the corresponding change for function argument passing to convert floating point args to integer. Finally make the corresponding change for the test code.
0cf7a56
to
14c7086
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems good to me. Let's let @andrewb1999 take a second look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Go ahead and merge once CI passes.
This patch tries to support Calyx constant op whose type is always unsigned integer; and the values and user-intended types are only specified via attributes