xref: /llvm-project/mlir/test/Dialect/Linalg/detensorize_entry_block.mlir (revision 441b672bbdc68ad88036f3e258759854c8283adb)
1// RUN: mlir-opt %s -allow-unregistered-dialect -pass-pipeline="builtin.module(func.func(linalg-detensorize))" | FileCheck %s
2
3#map = affine_map<() -> ()>
4func.func @main(%arg0: tensor<f32>) -> tensor<f32> {
5  %0 = tensor.empty() : tensor<f32>
6  %1 = linalg.generic {indexing_maps = [#map, #map], iterator_types = []} ins(%arg0 : tensor<f32>) outs(%0 : tensor<f32>) {
7  ^bb0(%in: f32, %out: f32):
8    linalg.yield %in : f32
9  } -> tensor<f32>
10  cf.br ^bb1(%1 : tensor<f32>)
11^bb1(%2: tensor<f32>):  // pred: ^bb0
12  return %2 : tensor<f32>
13}
14
15// CHECK-LABEL: @main
16// CHECK-SAME:       (%[[ARG0:.+]]: tensor<f32>) -> tensor<f32>
17// CHECK:   %[[EXTRACTED:.+]] = tensor.extract %[[ARG0]][] : tensor<f32>
18// CHECK: cf.br ^{{.*}}
19// CHECK: ^{{.*}}:
20// CHECK:   %[[ELEMENTS:.+]] = tensor.from_elements %[[EXTRACTED]] : tensor<f32>
21// CHECK:   return %[[ELEMENTS]] : tensor<f32>
22