summaryrefslogtreecommitdiffstats
path: root/mlir/test/Examples
diff options
context:
space:
mode:
authorRiver Riddle <riverriddle@google.com>2019-10-14 21:12:50 -0700
committerA. Unique TensorFlower <gardener@tensorflow.org>2019-10-14 21:13:45 -0700
commit300112e135f82b1f6faf8aa2ef266a27f07234de (patch)
tree01bce114b72da69b8fd88d727a8fcae2db1dd5dd /mlir/test/Examples
parentf29731d17f469722c73e33b6d503be0ab39cf907 (diff)
downloadbcm5719-llvm-300112e135f82b1f6faf8aa2ef266a27f07234de.tar.gz
bcm5719-llvm-300112e135f82b1f6faf8aa2ef266a27f07234de.zip
Merge Ch3 of the Toy tutorial into chapter 2.
This effectively rewrites Ch.2 to introduce dialects, operations, and registration instead of deferring to Ch.3. This allows for introducing the best practices up front(using ODS, registering operations, etc.), and limits the opaque API to the chapter document instead of the code. PiperOrigin-RevId: 274724289
Diffstat (limited to 'mlir/test/Examples')
-rw-r--r--mlir/test/Examples/Toy/Ch2/invalid.mlir8
-rw-r--r--mlir/test/Examples/Toy/Ch2/scalar.toy14
2 files changed, 17 insertions, 5 deletions
diff --git a/mlir/test/Examples/Toy/Ch2/invalid.mlir b/mlir/test/Examples/Toy/Ch2/invalid.mlir
index 919dbea5fdd..a8ceab9735e 100644
--- a/mlir/test/Examples/Toy/Ch2/invalid.mlir
+++ b/mlir/test/Examples/Toy/Ch2/invalid.mlir
@@ -1,11 +1,9 @@
-// RUN: toyc-ch2 %s -emit=mlir 2>&1
+// RUN: not toyc-ch2 %s -emit=mlir 2>&1
-
-// This IR is not "valid":
+// The following IR is not "valid":
// - toy.print should not return a value.
// - toy.print should take an argument.
// - There should be a block terminator.
-// This all round-trip since this is opaque for MLIR.
func @main() {
- %0 = "toy.print"() : () -> !toy.array<2, 3>
+ %0 = "toy.print"() : () -> tensor<2x3xf64>
}
diff --git a/mlir/test/Examples/Toy/Ch2/scalar.toy b/mlir/test/Examples/Toy/Ch2/scalar.toy
new file mode 100644
index 00000000000..0671f050129
--- /dev/null
+++ b/mlir/test/Examples/Toy/Ch2/scalar.toy
@@ -0,0 +1,14 @@
+# RUN: toyc-ch2 %s -emit=mlir 2>&1 | FileCheck %s
+
+def main() {
+ var a<2, 2> = 5.5;
+ print(a);
+}
+
+# CHECK-LABEL: func @main() {
+# CHECK-NEXT: %0 = "toy.constant"() {value = dense<5.500000e+00> : tensor<f64>} : () -> tensor<f64>
+# CHECK-NEXT: %1 = "toy.reshape"(%0) : (tensor<f64>) -> tensor<2x2xf64>
+# CHECK-NEXT: "toy.print"(%1) : (tensor<2x2xf64>) -> ()
+# CHECK-NEXT: "toy.return"() : () -> ()
+# CHECK-NEXT: }
+
OpenPOWER on IntegriCloud