-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Canonicalization of TTIR ops (#1670)
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.
- Loading branch information
1 parent
8f194e6
commit d129a9e
Showing
23 changed files
with
634 additions
and
244 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.