[Mlir-commits] [mlir] 444bb1f - [mlir][Toy] Remove unnecessary transpose from chapter 1 example
Mehdi Amini
llvmlistbot at llvm.org
Tue Jun 6 11:24:10 PDT 2023
Author: Andrey Portnoy
Date: 2023-06-06T11:23:35-07:00
New Revision: 444bb1f1bbbd7450fd30acc4ac1091fe916a740f
URL: https://github.com/llvm/llvm-project/commit/444bb1f1bbbd7450fd30acc4ac1091fe916a740f
DIFF: https://github.com/llvm/llvm-project/commit/444bb1f1bbbd7450fd30acc4ac1091fe916a740f.diff
LOG: [mlir][Toy] Remove unnecessary transpose from chapter 1 example
The call to 'multiply_transpose' in the initialization of the variable 'f' was
intended to have a shape mismatch. However the variable 'a' has shape <2, 3> and
the variable 'c' has shape <3, 2>, so the arguments 'transpose(a)' and 'c' have
in fact compatible shapes (<3, 2> both), the opposite of what is wanted here.
This commit removes the transpose so that arguments 'a' and 'c' have
incompatible shapes <2, 3> and <3, 2>, respectively.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D151897
Added:
Modified:
mlir/docs/Tutorials/Toy/Ch-1.md
mlir/test/Examples/Toy/Ch1/ast.toy
Removed:
################################################################################
diff --git a/mlir/docs/Tutorials/Toy/Ch-1.md b/mlir/docs/Tutorials/Toy/Ch-1.md
index 6838c34cbe4d0..09cee88db419d 100644
--- a/mlir/docs/Tutorials/Toy/Ch-1.md
+++ b/mlir/docs/Tutorials/Toy/Ch-1.md
@@ -61,9 +61,9 @@ def main() {
# trigger another specialization of `multiply_transpose`.
var e = multiply_transpose(c, d);
- # Finally, calling into `multiply_transpose` with incompatible shape will
- # trigger a shape inference error.
- var f = multiply_transpose(transpose(a), c);
+ # Finally, calling into `multiply_transpose` with incompatible shapes
+ # (<2, 3> and <3, 2>) will trigger a shape inference error.
+ var f = multiply_transpose(a, c);
}
```
@@ -74,7 +74,7 @@ The AST from the above code is fairly straightforward; here is a dump of it:
```
Module:
Function
- Proto 'multiply_transpose' @test/Examples/Toy/Ch1/ast.toy:4:1'
+ Proto 'multiply_transpose' @test/Examples/Toy/Ch1/ast.toy:4:1
Params: [a, b]
Block {
Return
@@ -87,7 +87,7 @@ Module:
]
} // Block
Function
- Proto 'main' @test/Examples/Toy/Ch1/ast.toy:8:1'
+ Proto 'main' @test/Examples/Toy/Ch1/ast.toy:8:1
Params: []
Block {
VarDecl a<> @test/Examples/Toy/Ch1/ast.toy:11:3
@@ -111,10 +111,8 @@ Module:
]
VarDecl f<> @test/Examples/Toy/Ch1/ast.toy:28:3
Call 'multiply_transpose' [ @test/Examples/Toy/Ch1/ast.toy:28:11
- Call 'transpose' [ @test/Examples/Toy/Ch1/ast.toy:28:30
- var: a @test/Examples/Toy/Ch1/ast.toy:28:40
- ]
- var: c @test/Examples/Toy/Ch1/ast.toy:28:44
+ var: a @test/Examples/Toy/Ch1/ast.toy:28:30
+ var: c @test/Examples/Toy/Ch1/ast.toy:28:33
]
} // Block
```
diff --git a/mlir/test/Examples/Toy/Ch1/ast.toy b/mlir/test/Examples/Toy/Ch1/ast.toy
index dc209a0ee3fa9..4af2d25fe1821 100644
--- a/mlir/test/Examples/Toy/Ch1/ast.toy
+++ b/mlir/test/Examples/Toy/Ch1/ast.toy
@@ -23,9 +23,9 @@ def main() {
# A new call with `<3, 2>` for both dimension will trigger another
# specialization of `multiply_transpose`.
var e = multiply_transpose(c, d);
- # Finally, calling into `multiply_transpose` with incompatible shape will
- # trigger a shape inference error.
- var f = multiply_transpose(transpose(a), c);
+ # Finally, calling into `multiply_transpose` with incompatible shapes
+ # (<2, 3> and <3, 2>) will trigger a shape inference error.
+ var f = multiply_transpose(a, c);
}
@@ -68,9 +68,7 @@ def main() {
# CHECK-NEXT: ]
# CHECK-NEXT: VarDecl f<> @{{.*}}ast.toy:28:3
# CHECK-NEXT: Call 'multiply_transpose' [ @{{.*}}ast.toy:28:11
-# CHECK-NEXT: Call 'transpose' [ @{{.*}}ast.toy:28:30
-# CHECK-NEXT: var: a @{{.*}}ast.toy:28:40
-# CHECK-NEXT: ]
-# CHECK-NEXT: var: c @{{.*}}ast.toy:28:44
+# CHECK-NEXT: var: a @{{.*}}ast.toy:28:30
+# CHECK-NEXT: var: c @{{.*}}ast.toy:28:33
# CHECK-NEXT: ]
-
+# CHECK-NEXT: } // Block
More information about the Mlir-commits
mailing list