brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.7 KiB · 5d66837 Raw
49 lines · plain
1// RUN: mlir-opt %s -split-input-file --linalg-specialize-generic-ops | FileCheck %s2 3#map = affine_map<(d0, d1, d2) -> (d1, d0)>4#map1 = affine_map<(d0, d1, d2) -> (d0, d1, d2)>5// This test checks that linalg.generic does not get incorrectly specialized to transform or broadcast.6// CHECK-LABEL: @transpose_and_broadcast7// CHECK: linalg.generic8func.func @transpose_and_broadcast(%arg0: tensor<7x8xf32>, %arg1: tensor<8x7x9xf32>) -> tensor<8x7x9xf32> {9  %res = linalg.generic {10    indexing_maps = [#map, #map1], iterator_types = ["parallel", "parallel", "parallel"]11  } ins(%arg0 : tensor<7x8xf32>) outs(%arg1 : tensor<8x7x9xf32>) {12  ^bb0(%in: f32, %out: f32):13    linalg.yield %in : f3214  } -> tensor<8x7x9xf32>15  return %res : tensor<8x7x9xf32>16}17 18// -----19 20#map = affine_map<(d0) -> (d0)>21// CHECK-LABEL: @neither_permutation_nor_broadcast22// CHECK: linalg.generic23func.func @neither_permutation_nor_broadcast(%init : tensor<8xi32>) -> tensor<8xi32> {24  %res = linalg.generic {25    indexing_maps = [#map], iterator_types = ["parallel"]26  } outs(%init: tensor<8xi32>) {27  ^bb0(%out: i32):28    linalg.yield %out: i3229  } -> tensor<8xi32>30  return %res : tensor<8xi32>31}32 33// -----34 35#map = affine_map<(d0) -> (d0)>36// CHECK-LABEL: func @not_copy37//  CHECK-NOT:    linalg.copy38//      CHECK:    linalg.generic39func.func @not_copy(%input: tensor<8xi32>, %init: tensor<8xi32>) -> tensor<8xi32> {40  %c0_i32 = arith.constant 0 : i3241  %res = linalg.generic {42    indexing_maps = [#map, #map], iterator_types = ["parallel"]43  } ins(%input: tensor<8xi32>) outs(%init: tensor<8xi32>) {44  ^bb0(%in: i32, %out: i32):45    linalg.yield %c0_i32 : i3246  } -> tensor<8xi32>47  return %res : tensor<8xi32>48}49