22 lines · plain
1// RUN: mlir-opt %s -allow-unregistered-dialect -pass-pipeline="builtin.module(func.func(linalg-detensorize))" | FileCheck %s2 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 : f329 } -> tensor<f32>10 cf.br ^bb1(%1 : tensor<f32>)11^bb1(%2: tensor<f32>): // pred: ^bb012 return %2 : tensor<f32>13}14 15// CHECK-LABEL: @main16// 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