[Mlir-commits] [mlir] [mlir][docs] Add more examples for the "canonical form" (PR #173667)
Mehdi Amini
llvmlistbot at llvm.org
Sun Dec 28 07:35:07 PST 2025
================
@@ -63,30 +63,37 @@ Some important things to think about w.r.t. canonicalization patterns:
* Canonicalize shouldn't lose the semantic of original operation: the original
information should always be recoverable from the transformed IR.
-For example, a pattern that transform
-
-```
- %transpose = linalg.transpose
- ins(%input : tensor<1x2x3xf32>)
- outs(%init1 : tensor<2x1x3xf32>)
- dimensions = [1, 0, 2]
- %out = linalg.transpose
- ins(%transpose: tensor<2x1x3xf32>)
- outs(%init2 : tensor<3x1x2xf32>)
- permutation = [2, 1, 0]
-```
-
-to
-
-```
- %out= linalg.transpose
- ins(%input : tensor<1x2x3xf32>)
- outs(%init2: tensor<3x1x2xf32>)
- permutation = [2, 0, 1]
-```
-
-is a good canonicalization pattern because it removes a redundant operation,
-making other analysis optimizations and more efficient.
+## What is the Canonical Form?
+
+There is no single formally defined canonical form in MLIR. Some dialects
+define multiple forms, depending on the transformation ([example](https://mlir.llvm.org/docs/Rationale/RationaleLinalgDialect/#interchangeability-of-formsa-nameformsa)).
----------------
joker-eph wrote:
```suggestion
There is no formally defined canonical form in MLIR.
```
This notion of "multiple canonical form" you imply isn't something that is embraced in the framework (or exists at all actually). Some transformations can have preconditions, but these are unrelated to canonicalization.
https://github.com/llvm/llvm-project/pull/173667
More information about the Mlir-commits
mailing list