xref: /llvm-project/mlir/test/Examples/Toy/Ch7/struct-opt.mlir (revision ee2c6cd9069fe0d8e7386ce53300e7645e4db792)
1// RUN: toyc-ch7 %s -emit=mlir -opt 2>&1 | FileCheck %s
2
3toy.func @main() {
4  %0 = toy.struct_constant [
5    [dense<4.000000e+00> : tensor<2x2xf64>], dense<4.000000e+00> : tensor<2x2xf64>
6  ] : !toy.struct<!toy.struct<tensor<*xf64>>, tensor<*xf64>>
7  %1 = toy.struct_access %0[0] : !toy.struct<!toy.struct<tensor<*xf64>>, tensor<*xf64>> -> !toy.struct<tensor<*xf64>>
8  %2 = toy.struct_access %1[0] : !toy.struct<tensor<*xf64>> -> tensor<*xf64>
9  toy.print %2 : tensor<*xf64>
10  toy.return
11}
12
13// CHECK-LABEL: toy.func @main
14// CHECK-NEXT: %[[CST:.*]] = toy.constant dense<4.0
15// CHECK-NEXT: toy.print %[[CST]]
16