Add polynomial.eval op for evaluation of a static polynomial#1271
Add polynomial.eval op for evaluation of a static polynomial#1271copybara-service[bot] merged 1 commit intogoogle:mainfrom
Conversation
j2kun
left a comment
There was a problem hiding this comment.
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.
| 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.
| 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.
| %result = polynomial.eval #poly, %x : !arith.constant | |
| %result = polynomial.eval #poly, %x : i32 |
|
@zmbekdemir if it's alright with you I can go ahead and cherry-pick your change and add my patches on top to submit it. |
|
@j2kun yes, go ahead please. |
|
Marking as pull_ready so I can patch it internally. The commit should still be attributed to you when it lands. |
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