From a6b427167e0560202529563cf94a210694038185 Mon Sep 17 00:00:00 2001 From: Lucy Fox Date: Fri, 17 Apr 2020 17:12:25 -0700 Subject: [PATCH] [MLIR] Update tutorial to add missing tests and bring directory paths and code snippets up to date. Summary: The tests referred to in Chapter 3 of the tutorial were missing from the tutorial test directory; this adds those missing tests. This also cleans up some stale directory paths and code snippets used throughout the tutorial. Differential Revision: https://reviews.llvm.org/D76809 --- mlir/test/Examples/Toy/Ch3/transpose_transpose.toy | 13 +++++-------- mlir/test/Examples/Toy/Ch3/trivial_reshape.toy | 12 ++++++------ mlir/test/Examples/Toy/Ch4/transpose_transpose.toy | 14 +++----------- mlir/test/Examples/Toy/Ch4/trivial_reshape.toy | 12 ++++++------ mlir/test/Examples/Toy/Ch5/transpose_transpose.toy | 14 +++----------- mlir/test/Examples/Toy/Ch5/trivial_reshape.toy | 12 ++++++------ mlir/test/Examples/Toy/Ch6/transpose_transpose.toy | 14 +++----------- mlir/test/Examples/Toy/Ch6/trivial_reshape.toy | 12 ++++++------ mlir/test/Examples/Toy/Ch7/transpose_transpose.toy | 14 +++----------- mlir/test/Examples/Toy/Ch7/trivial_reshape.toy | 12 ++++++------ 10 files changed, 47 insertions(+), 82 deletions(-) diff --git a/mlir/test/Examples/Toy/Ch3/transpose_transpose.toy b/mlir/test/Examples/Toy/Ch3/transpose_transpose.toy index 9945e7c..c686f6a 100644 --- a/mlir/test/Examples/Toy/Ch3/transpose_transpose.toy +++ b/mlir/test/Examples/Toy/Ch3/transpose_transpose.toy @@ -1,4 +1,4 @@ -# RUN: toyc-ch3 %s -emit=mlir 2>&1 | FileCheck %s +# RUN: toyc-ch3 %s -emit=mlir -opt 2>&1 | FileCheck %s # User defined generic function that operates on unknown shaped arguments def transpose_transpose(x) { @@ -13,13 +13,10 @@ def main() { # CHECK-LABEL: func @transpose_transpose( # CHECK-SAME: [[VAL_0:%.*]]: tensor<*xf64>) -> tensor<*xf64> -# CHECK: [[VAL_1:%.*]] = toy.transpose([[VAL_0]] : tensor<*xf64>) to tensor<*xf64> -# CHECK-NEXT: [[VAL_2:%.*]] = toy.transpose([[VAL_1]] : tensor<*xf64>) to tensor<*xf64> -# CHECK-NEXT: toy.return [[VAL_2]] : tensor<*xf64> +# CHECK-NEXT: toy.return [[VAL_0]] : tensor<*xf64> # CHECK-LABEL: func @main() -# CHECK-NEXT: [[VAL_3:%.*]] = toy.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64> -# CHECK-NEXT: [[VAL_4:%.*]] = toy.reshape([[VAL_3]] : tensor<2x3xf64>) to tensor<2x3xf64> -# CHECK-NEXT: [[VAL_5:%.*]] = toy.generic_call @transpose_transpose([[VAL_4]]) : (tensor<2x3xf64>) -> tensor<*xf64> -# CHECK-NEXT: toy.print [[VAL_5]] : tensor<*xf64> +# CHECK-NEXT: [[VAL_1:%.*]] = toy.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64> +# CHECK-NEXT: [[VAL_2:%.*]] = toy.generic_call @transpose_transpose([[VAL_1]]) : (tensor<2x3xf64>) -> tensor<*xf64> +# CHECK-NEXT: toy.print [[VAL_2]] : tensor<*xf64> # CHECK-NEXT: toy.return \ No newline at end of file diff --git a/mlir/test/Examples/Toy/Ch3/trivial_reshape.toy b/mlir/test/Examples/Toy/Ch3/trivial_reshape.toy index aa2c387..0f0b1af 100644 --- a/mlir/test/Examples/Toy/Ch3/trivial_reshape.toy +++ b/mlir/test/Examples/Toy/Ch3/trivial_reshape.toy @@ -1,4 +1,4 @@ -# RUN: toyc-ch3 %s -emit=mlir 2>&1 | FileCheck %s +# RUN: toyc-ch3 %s -emit=mlir -opt 2>&1 | FileCheck %s def main() { var a<2,1> = [1, 2]; @@ -8,9 +8,9 @@ def main() { } # CHECK-LABEL: func @main() -# CHECK-NEXT: [[VAL_0:%.*]] = toy.constant dense<[1.000000e+00, 2.000000e+00]> : tensor<2xf64> -# CHECK-NEXT: [[VAL_1:%.*]] = toy.reshape([[VAL_0]] : tensor<2xf64>) to tensor<2x1xf64> -# CHECK-NEXT: [[VAL_2:%.*]] = toy.reshape([[VAL_1]] : tensor<2x1xf64>) to tensor<2x1xf64> -# CHECK-NEXT: [[VAL_3:%.*]] = toy.reshape([[VAL_2]] : tensor<2x1xf64>) to tensor<2x1xf64> -# CHECK-NEXT: toy.print [[VAL_3]] : tensor<2x1xf64> +# CHECK-NEXT: [[VAL_0:%.*]] = toy.constant +# CHECK-SAME: dense<[ +# CHECK-SAME: [1.000000e+00], [2.000000e+00] +# CHECK-SAME: ]> : tensor<2x1xf64> +# CHECK-NEXT: toy.print [[VAL_0]] : tensor<2x1xf64> # CHECK-NEXT: toy.return \ No newline at end of file diff --git a/mlir/test/Examples/Toy/Ch4/transpose_transpose.toy b/mlir/test/Examples/Toy/Ch4/transpose_transpose.toy index 77bacec..2177c35 100644 --- a/mlir/test/Examples/Toy/Ch4/transpose_transpose.toy +++ b/mlir/test/Examples/Toy/Ch4/transpose_transpose.toy @@ -1,4 +1,4 @@ -# RUN: toyc-ch4 %s -emit=mlir 2>&1 | FileCheck %s +# RUN: toyc-ch4 %s -emit=mlir -opt 2>&1 | FileCheck %s # User defined generic function that operates on unknown shaped arguments def transpose_transpose(x) { @@ -11,15 +11,7 @@ def main() { print(b); } -# CHECK-LABEL: func @transpose_transpose( -# CHECK-SAME: [[VAL_0:%.*]]: tensor<*xf64>) -> tensor<*xf64> -# CHECK: [[VAL_1:%.*]] = toy.transpose([[VAL_0]] : tensor<*xf64>) to tensor<*xf64> -# CHECK-NEXT: [[VAL_2:%.*]] = toy.transpose([[VAL_1]] : tensor<*xf64>) to tensor<*xf64> -# CHECK-NEXT: toy.return [[VAL_2]] : tensor<*xf64> - # CHECK-LABEL: func @main() -# CHECK-NEXT: [[VAL_3:%.*]] = toy.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64> -# CHECK-NEXT: [[VAL_4:%.*]] = toy.reshape([[VAL_3]] : tensor<2x3xf64>) to tensor<2x3xf64> -# CHECK-NEXT: [[VAL_5:%.*]] = toy.generic_call @transpose_transpose([[VAL_4]]) : (tensor<2x3xf64>) -> tensor<*xf64> -# CHECK-NEXT: toy.print [[VAL_5]] : tensor<*xf64> +# CHECK-NEXT: [[VAL_1:%.*]] = toy.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64> +# CHECK-NEXT: toy.print [[VAL_1]] : tensor<2x3xf64> # CHECK-NEXT: toy.return \ No newline at end of file diff --git a/mlir/test/Examples/Toy/Ch4/trivial_reshape.toy b/mlir/test/Examples/Toy/Ch4/trivial_reshape.toy index 318bd07..453efa3 100644 --- a/mlir/test/Examples/Toy/Ch4/trivial_reshape.toy +++ b/mlir/test/Examples/Toy/Ch4/trivial_reshape.toy @@ -1,4 +1,4 @@ -# RUN: toyc-ch4 %s -emit=mlir 2>&1 | FileCheck %s +# RUN: toyc-ch4 %s -emit=mlir -opt 2>&1 | FileCheck %s def main() { var a<2,1> = [1, 2]; @@ -8,9 +8,9 @@ def main() { } # CHECK-LABEL: func @main() -# CHECK-NEXT: [[VAL_0:%.*]] = toy.constant dense<[1.000000e+00, 2.000000e+00]> : tensor<2xf64> -# CHECK-NEXT: [[VAL_1:%.*]] = toy.reshape([[VAL_0]] : tensor<2xf64>) to tensor<2x1xf64> -# CHECK-NEXT: [[VAL_2:%.*]] = toy.reshape([[VAL_1]] : tensor<2x1xf64>) to tensor<2x1xf64> -# CHECK-NEXT: [[VAL_3:%.*]] = toy.reshape([[VAL_2]] : tensor<2x1xf64>) to tensor<2x1xf64> -# CHECK-NEXT: toy.print [[VAL_3]] : tensor<2x1xf64> +# CHECK-NEXT: [[VAL_0:%.*]] = toy.constant +# CHECK-SAME: dense<[ +# CHECK-SAME: [1.000000e+00], [2.000000e+00] +# CHECK-SAME: ]> : tensor<2x1xf64> +# CHECK-NEXT: toy.print [[VAL_0]] : tensor<2x1xf64> # CHECK-NEXT: toy.return \ No newline at end of file diff --git a/mlir/test/Examples/Toy/Ch5/transpose_transpose.toy b/mlir/test/Examples/Toy/Ch5/transpose_transpose.toy index b038352..c0659c8 100644 --- a/mlir/test/Examples/Toy/Ch5/transpose_transpose.toy +++ b/mlir/test/Examples/Toy/Ch5/transpose_transpose.toy @@ -1,4 +1,4 @@ -# RUN: toyc-ch5 %s -emit=mlir 2>&1 | FileCheck %s +# RUN: toyc-ch5 %s -emit=mlir -opt 2>&1 | FileCheck %s # User defined generic function that operates on unknown shaped arguments def transpose_transpose(x) { @@ -11,15 +11,7 @@ def main() { print(b); } -# CHECK-LABEL: func @transpose_transpose( -# CHECK-SAME: [[VAL_0:%.*]]: tensor<*xf64>) -> tensor<*xf64> -# CHECK: [[VAL_1:%.*]] = toy.transpose([[VAL_0]] : tensor<*xf64>) to tensor<*xf64> -# CHECK-NEXT: [[VAL_2:%.*]] = toy.transpose([[VAL_1]] : tensor<*xf64>) to tensor<*xf64> -# CHECK-NEXT: toy.return [[VAL_2]] : tensor<*xf64> - # CHECK-LABEL: func @main() -# CHECK-NEXT: [[VAL_3:%.*]] = toy.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64> -# CHECK-NEXT: [[VAL_4:%.*]] = toy.reshape([[VAL_3]] : tensor<2x3xf64>) to tensor<2x3xf64> -# CHECK-NEXT: [[VAL_5:%.*]] = toy.generic_call @transpose_transpose([[VAL_4]]) : (tensor<2x3xf64>) -> tensor<*xf64> -# CHECK-NEXT: toy.print [[VAL_5]] : tensor<*xf64> +# CHECK-NEXT: [[VAL_1:%.*]] = toy.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64> +# CHECK-NEXT: toy.print [[VAL_1]] : tensor<2x3xf64> # CHECK-NEXT: toy.return \ No newline at end of file diff --git a/mlir/test/Examples/Toy/Ch5/trivial_reshape.toy b/mlir/test/Examples/Toy/Ch5/trivial_reshape.toy index 48828c4..453efa3 100644 --- a/mlir/test/Examples/Toy/Ch5/trivial_reshape.toy +++ b/mlir/test/Examples/Toy/Ch5/trivial_reshape.toy @@ -1,4 +1,4 @@ -# RUN: toyc-ch5 %s -emit=mlir 2>&1 | FileCheck %s +# RUN: toyc-ch4 %s -emit=mlir -opt 2>&1 | FileCheck %s def main() { var a<2,1> = [1, 2]; @@ -8,9 +8,9 @@ def main() { } # CHECK-LABEL: func @main() -# CHECK-NEXT: [[VAL_0:%.*]] = toy.constant dense<[1.000000e+00, 2.000000e+00]> : tensor<2xf64> -# CHECK-NEXT: [[VAL_1:%.*]] = toy.reshape([[VAL_0]] : tensor<2xf64>) to tensor<2x1xf64> -# CHECK-NEXT: [[VAL_2:%.*]] = toy.reshape([[VAL_1]] : tensor<2x1xf64>) to tensor<2x1xf64> -# CHECK-NEXT: [[VAL_3:%.*]] = toy.reshape([[VAL_2]] : tensor<2x1xf64>) to tensor<2x1xf64> -# CHECK-NEXT: toy.print [[VAL_3]] : tensor<2x1xf64> +# CHECK-NEXT: [[VAL_0:%.*]] = toy.constant +# CHECK-SAME: dense<[ +# CHECK-SAME: [1.000000e+00], [2.000000e+00] +# CHECK-SAME: ]> : tensor<2x1xf64> +# CHECK-NEXT: toy.print [[VAL_0]] : tensor<2x1xf64> # CHECK-NEXT: toy.return \ No newline at end of file diff --git a/mlir/test/Examples/Toy/Ch6/transpose_transpose.toy b/mlir/test/Examples/Toy/Ch6/transpose_transpose.toy index 5ddfbc2..ac710fe 100644 --- a/mlir/test/Examples/Toy/Ch6/transpose_transpose.toy +++ b/mlir/test/Examples/Toy/Ch6/transpose_transpose.toy @@ -1,4 +1,4 @@ -# RUN: toyc-ch6 %s -emit=mlir 2>&1 | FileCheck %s +# RUN: toyc-ch6 %s -emit=mlir -opt 2>&1 | FileCheck %s # User defined generic function that operates on unknown shaped arguments def transpose_transpose(x) { @@ -11,15 +11,7 @@ def main() { print(b); } -# CHECK-LABEL: func @transpose_transpose( -# CHECK-SAME: [[VAL_0:%.*]]: tensor<*xf64>) -> tensor<*xf64> -# CHECK: [[VAL_1:%.*]] = toy.transpose([[VAL_0]] : tensor<*xf64>) to tensor<*xf64> -# CHECK-NEXT: [[VAL_2:%.*]] = toy.transpose([[VAL_1]] : tensor<*xf64>) to tensor<*xf64> -# CHECK-NEXT: toy.return [[VAL_2]] : tensor<*xf64> - # CHECK-LABEL: func @main() -# CHECK-NEXT: [[VAL_3:%.*]] = toy.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64> -# CHECK-NEXT: [[VAL_4:%.*]] = toy.reshape([[VAL_3]] : tensor<2x3xf64>) to tensor<2x3xf64> -# CHECK-NEXT: [[VAL_5:%.*]] = toy.generic_call @transpose_transpose([[VAL_4]]) : (tensor<2x3xf64>) -> tensor<*xf64> -# CHECK-NEXT: toy.print [[VAL_5]] : tensor<*xf64> +# CHECK-NEXT: [[VAL_1:%.*]] = toy.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64> +# CHECK-NEXT: toy.print [[VAL_1]] : tensor<2x3xf64> # CHECK-NEXT: toy.return \ No newline at end of file diff --git a/mlir/test/Examples/Toy/Ch6/trivial_reshape.toy b/mlir/test/Examples/Toy/Ch6/trivial_reshape.toy index 6fa9f68..453efa3 100644 --- a/mlir/test/Examples/Toy/Ch6/trivial_reshape.toy +++ b/mlir/test/Examples/Toy/Ch6/trivial_reshape.toy @@ -1,4 +1,4 @@ -# RUN: toyc-ch6 %s -emit=mlir 2>&1 | FileCheck %s +# RUN: toyc-ch4 %s -emit=mlir -opt 2>&1 | FileCheck %s def main() { var a<2,1> = [1, 2]; @@ -8,9 +8,9 @@ def main() { } # CHECK-LABEL: func @main() -# CHECK-NEXT: [[VAL_0:%.*]] = toy.constant dense<[1.000000e+00, 2.000000e+00]> : tensor<2xf64> -# CHECK-NEXT: [[VAL_1:%.*]] = toy.reshape([[VAL_0]] : tensor<2xf64>) to tensor<2x1xf64> -# CHECK-NEXT: [[VAL_2:%.*]] = toy.reshape([[VAL_1]] : tensor<2x1xf64>) to tensor<2x1xf64> -# CHECK-NEXT: [[VAL_3:%.*]] = toy.reshape([[VAL_2]] : tensor<2x1xf64>) to tensor<2x1xf64> -# CHECK-NEXT: toy.print [[VAL_3]] : tensor<2x1xf64> +# CHECK-NEXT: [[VAL_0:%.*]] = toy.constant +# CHECK-SAME: dense<[ +# CHECK-SAME: [1.000000e+00], [2.000000e+00] +# CHECK-SAME: ]> : tensor<2x1xf64> +# CHECK-NEXT: toy.print [[VAL_0]] : tensor<2x1xf64> # CHECK-NEXT: toy.return \ No newline at end of file diff --git a/mlir/test/Examples/Toy/Ch7/transpose_transpose.toy b/mlir/test/Examples/Toy/Ch7/transpose_transpose.toy index 804cdb8..f268425 100644 --- a/mlir/test/Examples/Toy/Ch7/transpose_transpose.toy +++ b/mlir/test/Examples/Toy/Ch7/transpose_transpose.toy @@ -1,4 +1,4 @@ -# RUN: toyc-ch7 %s -emit=mlir 2>&1 | FileCheck %s +# RUN: toyc-ch7 %s -emit=mlir -opt 2>&1 | FileCheck %s # User defined generic function that operates on unknown shaped arguments def transpose_transpose(x) { @@ -11,15 +11,7 @@ def main() { print(b); } -# CHECK-LABEL: func @transpose_transpose( -# CHECK-SAME: [[VAL_0:%.*]]: tensor<*xf64>) -> tensor<*xf64> -# CHECK: [[VAL_1:%.*]] = toy.transpose([[VAL_0]] : tensor<*xf64>) to tensor<*xf64> -# CHECK-NEXT: [[VAL_2:%.*]] = toy.transpose([[VAL_1]] : tensor<*xf64>) to tensor<*xf64> -# CHECK-NEXT: toy.return [[VAL_2]] : tensor<*xf64> - # CHECK-LABEL: func @main() -# CHECK-NEXT: [[VAL_3:%.*]] = toy.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64> -# CHECK-NEXT: [[VAL_4:%.*]] = toy.reshape([[VAL_3]] : tensor<2x3xf64>) to tensor<2x3xf64> -# CHECK-NEXT: [[VAL_5:%.*]] = toy.generic_call @transpose_transpose([[VAL_4]]) : (tensor<2x3xf64>) -> tensor<*xf64> -# CHECK-NEXT: toy.print [[VAL_5]] : tensor<*xf64> +# CHECK-NEXT: [[VAL_1:%.*]] = toy.constant dense<{{\[\[}}1.000000e+00, 2.000000e+00, 3.000000e+00], [4.000000e+00, 5.000000e+00, 6.000000e+00]]> : tensor<2x3xf64> +# CHECK-NEXT: toy.print [[VAL_1]] : tensor<2x3xf64> # CHECK-NEXT: toy.return \ No newline at end of file diff --git a/mlir/test/Examples/Toy/Ch7/trivial_reshape.toy b/mlir/test/Examples/Toy/Ch7/trivial_reshape.toy index 73209d8..453efa3 100644 --- a/mlir/test/Examples/Toy/Ch7/trivial_reshape.toy +++ b/mlir/test/Examples/Toy/Ch7/trivial_reshape.toy @@ -1,4 +1,4 @@ -# RUN: toyc-ch7 %s -emit=mlir 2>&1 | FileCheck %s +# RUN: toyc-ch4 %s -emit=mlir -opt 2>&1 | FileCheck %s def main() { var a<2,1> = [1, 2]; @@ -8,9 +8,9 @@ def main() { } # CHECK-LABEL: func @main() -# CHECK-NEXT: [[VAL_0:%.*]] = toy.constant dense<[1.000000e+00, 2.000000e+00]> : tensor<2xf64> -# CHECK-NEXT: [[VAL_1:%.*]] = toy.reshape([[VAL_0]] : tensor<2xf64>) to tensor<2x1xf64> -# CHECK-NEXT: [[VAL_2:%.*]] = toy.reshape([[VAL_1]] : tensor<2x1xf64>) to tensor<2x1xf64> -# CHECK-NEXT: [[VAL_3:%.*]] = toy.reshape([[VAL_2]] : tensor<2x1xf64>) to tensor<2x1xf64> -# CHECK-NEXT: toy.print [[VAL_3]] : tensor<2x1xf64> +# CHECK-NEXT: [[VAL_0:%.*]] = toy.constant +# CHECK-SAME: dense<[ +# CHECK-SAME: [1.000000e+00], [2.000000e+00] +# CHECK-SAME: ]> : tensor<2x1xf64> +# CHECK-NEXT: toy.print [[VAL_0]] : tensor<2x1xf64> # CHECK-NEXT: toy.return \ No newline at end of file -- 2.7.4