-
Notifications
You must be signed in to change notification settings - Fork 57
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
Add polynomial.eval op for evaluation of a static polynomial #1271
base: main
Are you sure you want to change the base?
Conversation
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.
So the tablegen looks mostly good to me! A few small nits, and then I'd suggest adding a test using this new syntax in tests/Dialect/Polynomial/IR/
(could be in, say, int_coefficients.mlir
or a new file if you prefer). This will ensure that heir-opt
can run, parse+print the syntax you've chosen, as well as run any IR verifiers.
let description = [{ | ||
Evaluates the result of a polynomial specified as a static attribute at a given SSA value. | ||
The result represents the evaluation of the polynomial at the input value and produces | ||
a corresponding constant value. |
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.
a corresponding constant value. | |
a corresponding scalar value. |
"constant" would imply statically known, and if the input is an SSA value then it's not in general.
); | ||
|
||
let results = (outs AnyType:$result); | ||
let assemblyFormat = "$polynomial attr-dict `polynomial` $value type($value) `->` type($result)"; |
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.
let assemblyFormat = "$polynomial attr-dict `polynomial` $value type($value) `->` type($result)"; | |
let assemblyFormat = "operands attr-dict `:` type($value)"; |
```mlir | ||
#poly = #polynomial.int_polynomial<x**2 + 2*x + 1> | ||
%x = arith.constant 5 : i32 | ||
%result = polynomial.eval #poly, %x : !arith.constant |
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.
%result = polynomial.eval #poly, %x : !arith.constant | |
%result = polynomial.eval #poly, %x : i32 |
This is the definition for polynomial.eval op. This operation builds without error but I am not sure if it is the final version. Insights and recommendations are appreciated. #1217