brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.5 KiB · bd9977f Raw
62 lines · plain
1// RUN: mlir-opt %s -test-linalg-elementwise-fusion-patterns=fuse-generic-ops-control -split-input-file | FileCheck %s2 3#map = affine_map<(d0, d1) -> (d0, d1)>4func.func @drop_unused_producer_result(%arg0 : tensor<?x?xf32>,5    %arg1 : tensor<?x?xf32>) -> tensor<?x?xf32> {6  %0:2 = linalg.generic {7      indexing_maps = [#map, #map, #map],8      iterator_types = ["parallel", "parallel"]}9      ins(%arg0 : tensor<?x?xf32>) outs(%arg0, %arg0  : tensor<?x?xf32>, tensor<?x?xf32>) {10    ^bb0(%b0: f32, %b1: f32, %b2: f32):11      %1 = arith.addf %b0, %b0 : f3212      %2 = arith.mulf %b0, %b0 : f3213      linalg.yield %1, %2 : f32, f3214    } -> (tensor<?x?xf32>, tensor<?x?xf32>)15  %3 = linalg.generic {16      indexing_maps = [#map, #map, #map],17      iterator_types = ["parallel", "parallel"]}18      ins(%0#0, %arg1 : tensor<?x?xf32>, tensor<?x?xf32>) outs(%arg0  : tensor<?x?xf32>) {19    ^bb0(%b0: f32, %b1: f32, %b2: f32):20      %4 = arith.subf %b0, %b1 : f3221      linalg.yield %4 : f3222    } -> tensor<?x?xf32>23  return %3 : tensor<?x?xf32>24}25// CHECK-LABEL: func @drop_unused_producer_result26//  CHECK-SAME:   %[[ARG0:[a-zA-Z0-9]+]]: tensor<?x?xf32>27//  CHECK-SAME:   %[[ARG1:[a-zA-Z0-9]+]]: tensor<?x?xf32>28//       CHECK:   %[[FUSED_OP:.+]] = linalg.generic29//  CHECK-SAME:       ins(%[[ARG0]], %[[ARG1]] :30//       CHECK:   return %[[FUSED_OP]]31 32// -----33 34#map = affine_map<(d0) -> (d0)>35func.func @handle_unused_operands(%arg0: tensor<8xf32>, %arg1: tensor<8xf32>) -> tensor<8xf32> {36  %cst_0 = arith.constant 0.000000e+00 : f3237  %cst_1 = arith.constant 1.000000e+00 : f3238  %0:2 = linalg.generic {indexing_maps = [#map, #map], iterator_types = ["parallel"]} outs(%arg0, %arg1 : tensor<8xf32>, tensor<8xf32>) {39  ^bb0(%out: f32, %out_2: f32):40    %1 = linalg.index 0 : index41    %2 = arith.index_cast %1 : index to i6442    %3 = arith.sitofp %2 : i64 to f3243    %4 = arith.divf %3, %cst_0 : f3244    linalg.yield %3, %4 : f32, f3245  } -> (tensor<8xf32>, tensor<8xf32>)46  linalg.generic {indexing_maps = [#map], iterator_types = ["parallel"]} ins(%0#1 : tensor<8xf32>) {47  ^bb0(%in: f32):48    %2 = arith.cmpf one, %in, %cst_1 : f3249    cf.assert %2, "Side effect op"50    linalg.yield51  }52  func.return %arg1 : tensor<8xf32>53}54 55// CHECK-LABEL: func @handle_unused_operands56//  CHECK-SAME:   %[[ARG0:[a-zA-Z0-9]+]]: tensor<8xf32>57//  CHECK-SAME:   %[[ARG1:[a-zA-Z0-9]+]]: tensor<8xf32>58//       CHECK:   %[[EMPTY:.+]] = tensor.empty() : tensor<8xf32>59//       CHECK:   %[[FUSED_OP:.+]] = linalg.generic60//  CHECK-SAME:       outs(%[[EMPTY]] :61//   CHECK-NOT:   linalg.generic62