[Mlir-commits] [mlir] bfedf16 - [MLIR] Fix tensor shapes in Toy chapter 1

Thomas Preud'homme llvmlistbot at llvm.org
Fri Jan 27 02:09:31 PST 2023


Author: Thomas Preud'homme
Date: 2023-01-27T10:09:25Z
New Revision: bfedf169f4261a0fbe097f4a717d375dda2503c4

URL: https://github.com/llvm/llvm-project/commit/bfedf169f4261a0fbe097f4a717d375dda2503c4
DIFF: https://github.com/llvm/llvm-project/commit/bfedf169f4261a0fbe097f4a717d375dda2503c4.diff

LOG: [MLIR] Fix tensor shapes in Toy chapter 1

In Toy tutorial chapter 1, multiply_transpose() is called with b<2, 3>
and c<3, 2> when both parameters should have the same shape. This commit
fixes this by instead using c and d as parameters and fix a comment typo
where c and d are mentioned to have shape <2, 2> when they actually have
shape <3, 2>.

Reviewed By: mehdi_amini

Differential Revision: https://reviews.llvm.org/D142622

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 c851f18bf1cb2..6838c34cbe4d0 100644
--- a/mlir/docs/Tutorials/Toy/Ch-1.md
+++ b/mlir/docs/Tutorials/Toy/Ch-1.md
@@ -59,7 +59,7 @@ def main() {
 
   # A new call with <3, 2> (instead of <2, 3>) for both dimensions will
   # trigger another specialization of `multiply_transpose`.
-  var e = multiply_transpose(b, c);
+  var e = multiply_transpose(c, d);
 
   # Finally, calling into `multiply_transpose` with incompatible shape will
   # trigger a shape inference error.
@@ -106,8 +106,8 @@ Module:
         ]
       VarDecl e<> @test/Examples/Toy/Ch1/ast.toy:25:3
         Call 'multiply_transpose' [ @test/Examples/Toy/Ch1/ast.toy:25:11
-          var: b @test/Examples/Toy/Ch1/ast.toy:25:30
-          var: c @test/Examples/Toy/Ch1/ast.toy:25:33
+          var: c @test/Examples/Toy/Ch1/ast.toy:25:30
+          var: d @test/Examples/Toy/Ch1/ast.toy:25:33
         ]
       VarDecl f<> @test/Examples/Toy/Ch1/ast.toy:28:3
         Call 'multiply_transpose' [ @test/Examples/Toy/Ch1/ast.toy:28:11

diff  --git a/mlir/test/Examples/Toy/Ch1/ast.toy b/mlir/test/Examples/Toy/Ch1/ast.toy
index 19f525a48808c..dc209a0ee3fa9 100644
--- a/mlir/test/Examples/Toy/Ch1/ast.toy
+++ b/mlir/test/Examples/Toy/Ch1/ast.toy
@@ -15,14 +15,14 @@ def main() {
   var b<2, 3> = [1, 2, 3, 4, 5, 6];
 
   # This call will specialize `multiply_transpose` with <2, 3> for both
-  # arguments and deduce a return type of <2, 2> in initialization of `c`.
+  # arguments and deduce a return type of <3, 2> in initialization of `c`.
   var c = multiply_transpose(a, b);
   # A second call to `multiply_transpose` with <2, 3> for both arguments will
-  # reuse the previously specialized and inferred version and return `<2, 2>`
+  # reuse the previously specialized and inferred version and return `<3, 2>`
   var d = multiply_transpose(b, a);
-  # A new call with `<2, 2>` for both dimension will trigger another
+  # A new call with `<3, 2>` for both dimension will trigger another
   # specialization of `multiply_transpose`.
-  var e = multiply_transpose(b, c);
+  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);
@@ -63,8 +63,8 @@ def main() {
 # CHECK-NEXT:           ]
 # CHECK-NEXT:         VarDecl e<> @{{.*}}ast.toy:25:3
 # CHECK-NEXT:           Call 'multiply_transpose' [ @{{.*}}ast.toy:25:11
-# CHECK-NEXT:             var: b @{{.*}}ast.toy:25:30
-# CHECK-NEXT:             var: c @{{.*}}ast.toy:25:33
+# CHECK-NEXT:             var: c @{{.*}}ast.toy:25:30
+# CHECK-NEXT:             var: d @{{.*}}ast.toy:25:33
 # CHECK-NEXT:           ]
 # CHECK-NEXT:         VarDecl f<> @{{.*}}ast.toy:28:3
 # CHECK-NEXT:           Call 'multiply_transpose' [ @{{.*}}ast.toy:28:11


        


More information about the Mlir-commits mailing list