Files
clang-p2996/mlir/test/Examples/Toy/Ch7/struct-opt.mlir
River Riddle ee2c6cd906 [mlir][toy] Define a FuncOp operation in toy and drop the dependence on FuncOp
FuncOp is being moved out of the builtin dialect, and defining a custom
toy operation showcases various aspects of defining function-like operation
(e.g. inlining, passes, etc.).

Differential Revision: https://reviews.llvm.org/D121264
2022-03-15 14:55:51 -07:00

16 lines
608 B
MLIR

// RUN: toyc-ch7 %s -emit=mlir -opt 2>&1 | FileCheck %s
toy.func @main() {
%0 = toy.struct_constant [
[dense<4.000000e+00> : tensor<2x2xf64>], dense<4.000000e+00> : tensor<2x2xf64>
] : !toy.struct<!toy.struct<tensor<*xf64>>, tensor<*xf64>>
%1 = toy.struct_access %0[0] : !toy.struct<!toy.struct<tensor<*xf64>>, tensor<*xf64>> -> !toy.struct<tensor<*xf64>>
%2 = toy.struct_access %1[0] : !toy.struct<tensor<*xf64>> -> tensor<*xf64>
toy.print %2 : tensor<*xf64>
toy.return
}
// CHECK-LABEL: toy.func @main
// CHECK-NEXT: %[[CST:.*]] = toy.constant dense<4.0
// CHECK-NEXT: toy.print %[[CST]]