brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.7 KiB · 2332b28 Raw
57 lines · plain
1// RUN: mlir-opt %s -linalg-morph-ops=named-to-category -split-input-file | FileCheck %s2 3// CHECK: @exp(%[[A:.+]]: tensor<16x8xf32>, %[[B:.+]]: tensor<16x8xf32>) ->  tensor<16x8xf32> {4// CHECK: {{.*}} = linalg.elementwise5// CHECK-SAME:       kind=#linalg.elementwise_kind<exp>6// CHECK-SAME:       ins(%[[A]] : tensor<16x8xf32>)7// CHECK-SAME:       outs(%[[B]] : tensor<16x8xf32>) -> tensor<16x8xf32>8//9func.func @exp(%A : tensor<16x8xf32>, %B : tensor<16x8xf32>) ->  tensor<16x8xf32> {10  %exp = linalg.exp ins(%A : tensor<16x8xf32>) outs(%B :  tensor<16x8xf32>) -> tensor<16x8xf32>11  return %exp :  tensor<16x8xf32>12}13 14// ----15 16// CHECK: @add(%[[A:.+]]: tensor<16x8xf32>, %[[B:.+]]: tensor<16x8xf32>, %[[C:.+]]: tensor<16x8xf32>) ->  tensor<16x8xf32> {17// CHECK: {{.*}} = linalg.elementwise18// CHECK-SAME:       kind=#linalg.elementwise_kind<add>19// CHECK-SAME:       ins(%[[A]], %[[B]] : tensor<16x8xf32>, tensor<16x8xf32>)20// CHECK-SAME:       outs(%[[C]] : tensor<16x8xf32>) -> tensor<16x8xf32>21//22func.func @add(%A : tensor<16x8xf32>, %B: tensor<16x8xf32>, %C : tensor<16x8xf32>) ->  tensor<16x8xf32> {23  %add = linalg.add ins(%A, %B : tensor<16x8xf32>, tensor<16x8xf32>) outs(%C :  tensor<16x8xf32>) -> tensor<16x8xf32>24  return %add :  tensor<16x8xf32>25}26 27// ----28 29// CHECK: @sub(%[[A:.+]]: tensor<16x8xf32>, %[[B:.+]]: tensor<16x8xf32>, %[[C:.+]]: tensor<16x8xf32>) -> tensor<16x8xf32> {30// CHECK: {{.*}} = linalg.elementwise31// CHECK-SAME:       kind=#linalg.elementwise_kind<sub>32// CHECK-SAME:       ins(%[[A]], %[[B]] : tensor<16x8xf32>, tensor<16x8xf32>)33// CHECK-SAME:       outs(%[[C]] : tensor<16x8xf32>)34//35func.func @sub(%A : tensor<16x8xf32>, %B: tensor<16x8xf32>, %C : tensor<16x8xf32>) -> tensor<16x8xf32> {36  %sub = linalg.sub ins(%A, %B : tensor<16x8xf32>, tensor<16x8xf32>) outs(%C :  tensor<16x8xf32>) -> tensor<16x8xf32>37  return %sub : tensor<16x8xf32>38}39 40// ----41 42// CHECK: @ternary_select(%[[A:.+]]: tensor<4x8x16xi1>, %[[B:.+]]: tensor<4x8x16xf32>, %[[C:.+]]: tensor<4x8x16xf32>)43// CHECK:   %[[E:.+]] =  tensor.empty() : tensor<4x8x16xf32>44// CHECK: {{.*}} = linalg.elementwise45// CHECK-SAME:       kind=#linalg.elementwise_kind<select>46// CHECK-SAME:       ins(%[[A]], %[[B]], %[[C]] : tensor<4x8x16xi1>, tensor<4x8x16xf32>, tensor<4x8x16xf32>)47// CHECK-SAME:       outs(%[[E]] : tensor<4x8x16xf32>) -> tensor<4x8x16xf32>48//49func.func @ternary_select(%A: tensor<4x8x16xi1>, %B: tensor<4x8x16xf32>, %C: tensor<4x8x16xf32>)50             -> tensor<4x8x16xf32> {51  %empty = tensor.empty() : tensor<4x8x16xf32>52  %select = linalg.select53              ins(%A, %B, %C : tensor<4x8x16xi1>, tensor<4x8x16xf32>, tensor<4x8x16xf32>)54              outs(%empty: tensor<4x8x16xf32>) -> tensor<4x8x16xf32>55  return %select : tensor<4x8x16xf32>56}57