-
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
TTIR constant materialization #1548
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.
Nice, thanks for adding this! I've planned to do this long time ago but wasn't sure if that will do the trick without other changes to enable canonicalization. I also wasn't sure if we can rely that folders will always be activated during compilation and remove explicit conversions, mlir documentation wasn't very helpful on this, did you find a confirmation somewhere?
@mrakitaTT Yeah, I had to dive into MLIR's source code, during legalization it first tries with fold, and only then try with patterns as a fallback. |
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.
Great change!
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.
This looks great! Perhaps we can add a test that exercises this case?
@nsmithtt There are already some tests that cover |
0d2758b
to
4c38555
Compare
2ec80f3
to
7222b62
Compare
7222b62
to
9ab0add
Compare
* TTIR constant materialization * GetDimensionSizeOp removed from decomp and realized through fold + materialization * Added test for get_dimension_size -> constant conversion
ConstantOp
in the TTIR dialect has aConstantLike
trait so constants can be materialized intottir.constant
operation. We already have one use case, whereGetDimensionSizeOp
is folded intoAttribute
, so instead of decomposition, a folding intoAttribute
and materialization intoConstantOp
takes a more natural approach.For all future use cases of
FooOpToConstantOp
conversions, instead of implementing pattern rewriting, it's enough to foldFooOp
intomlir::ElementsAttr
.