brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.3 KiB · 35eeffc Raw
27 lines · plain
1// RUN: mlir-opt -test-linalg-drop-unit-dims --split-input-file %s | FileCheck %s2 3// Drop only the outermost unit dimension (controlled using a control function)4func.func @drop_outermost_unit_dims(%arg0: tensor<1x1x42xf32>) -> tensor<1x1x42xf32> {5  %0 = tensor.empty() : tensor<1x1x42xf32>6  %1 = linalg.generic {7    indexing_maps = [affine_map<(d0, d1, d2) -> (d0, d1, d2)>,8                     affine_map<(d0, d1, d2) -> (d0, d1, d2)>],9    iterator_types = ["parallel", "parallel", "parallel"]}10    ins(%arg0 : tensor<1x1x42xf32>) outs(%0 : tensor<1x1x42xf32>) {11      ^bb0(%b0: f32, %b1 : f32):12        %2 = arith.addf %b0, %b1 : f3213        linalg.yield %2 : f3214    } -> tensor<1x1x42xf32>15  return %1 : tensor<1x1x42xf32>16}17// CHECK-LABEL: func @drop_outermost_unit_dims18//  CHECK-SAME:     %[[ARG0:.+]]: tensor<1x1x42xf32>19//       CHECK:   %[[OUTS:.+]] = tensor.empty()20//       CHECK:   %[[ARG0_RESHAPE:.+]] = tensor.collapse_shape %[[ARG0]] {{\[}}[0, 1], [2]{{\]}}21//       CHECK:   %[[OUTS_RESHAPE:.+]] = tensor.collapse_shape %[[OUTS]] {{\[}}[0, 1], [2]{{\]}}22//       CHECK:   %[[GENERIC:.+]] = linalg.generic23//  CHECK-SAME:       ins(%[[ARG0_RESHAPE]] :24//  CHECK-SAME:       outs(%[[OUTS_RESHAPE]] :25//       CHECK:   %[[EXPAND_SHAPE:.+]] = tensor.expand_shape %[[GENERIC]] {{\[}}[0, 1], [2]{{\]}}26//       CHECK:   return %[[EXPAND_SHAPE]]27