You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To improve the efficiency and reliability of our MLIR compiler, we need to introduce a canonicalizer pass. This pass should apply a range of canonicalization patterns that simplify and normalize the intermediate representation (IR). Canonicalization makes IR easier to optimize and analyze by reducing redundant patterns and ensuring consistency in how operations are represented. Currently, our compiler lacks a centralized approach for defining and managing these patterns, making it difficult to ensure consistent transformations across components.
The text was updated successfully, but these errors were encountered:
Canonicalization can be roughly divided into three forms:
1. Traits (properties) of some ops that allows them to be folded
(Involution, Idempotence)
2. Per op foldings
4. Per op canonicalization (pattern rewriters)
The first one allows us to decleratively add folding for a large class
of ops. While traits like `Involution` already exists in `MLIR`
infrastructure it doesn't account for DPS, so I added a new one that
takes care of it.
The second one allows us in practice to define some simple graph
rewritings where we replace the producing value of op with some existing
value (or constant).
The third one gives us the most freedom, where we can do arbitrary graph
rewritings, we usually use it when we have to create a new op during
rewriting.
I added a `canonicalize` pass both before and after
`ttir-to-ttir-decomposition-pass` in `ttir-to-ttnn-backend-pipeline`, as
there are many graph rewritings during that pass, so we might benefit
form canonicalization both before and after.
I plan to cover one big part of canonicalization in the future, and
that's constant folding. I will also write a short document on adding a
canonicalization for new and existing ops. While this PR covers a lot of
patterns, it's definitely not an exhaustive list. This MLIR
[doc](https://mlir.llvm.org/docs/Canonicalization/) is already a great
source of information, I just believe we might also benefit from the
additional context of TTIR dialect.
This PR should cover a big part of
#1264, as I said the
missing part is constant folding.
To improve the efficiency and reliability of our MLIR compiler, we need to introduce a canonicalizer pass. This pass should apply a range of canonicalization patterns that simplify and normalize the intermediate representation (IR). Canonicalization makes IR easier to optimize and analyze by reducing redundant patterns and ensuring consistency in how operations are represented. Currently, our compiler lacks a centralized approach for defining and managing these patterns, making it difficult to ensure consistent transformations across components.
The text was updated successfully, but these errors were encountered: