brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.6 KiB · 7871ae0 Raw
35 lines · plain
1// RUN: mlir-opt -test-linalg-elementwise-fusion-patterns=fuse-multiuse-producer -split-input-file %s | FileCheck %s2 3#map = affine_map<(d0, d1) -> (d0, d1)>4func.func @multi_use_producer(%arg0 : tensor<?x?xf32>, %arg1 : tensor<?x?xf32>,5    %arg2 : tensor<?x?xf32>, %arg3 : tensor<?x?xf32>, %arg4 : tensor<?x?xf32>)6    -> (tensor<?x?xf32>, tensor<?x?xf32>, tensor<?x?xf32>) {7  %0:2 = linalg.generic {8      indexing_maps = [#map, #map, #map],9      iterator_types = ["parallel", "parallel"]}10      ins(%arg0 : tensor<?x?xf32>)11      outs(%arg1, %arg2 : tensor<?x?xf32>, tensor<?x?xf32>) {12  ^bb0(%b0: f32, %b1 : f32, %b2 : f32):13    %1 = arith.addf %b0, %b1 : f3214    linalg.yield %1, %1 : f32, f3215  } -> (tensor<?x?xf32>, tensor<?x?xf32>)16  %2 = linalg.generic {17      indexing_maps = [#map, #map, #map],18      iterator_types = ["parallel", "parallel"]}19      ins(%0#1, %arg3 : tensor<?x?xf32>, tensor<?x?xf32>)20      outs(%arg4 : tensor<?x?xf32>) {21  ^bb0(%b0 : f32, %b1 : f32, %b2 : f32):22    %3 = arith.mulf %b0, %b1 : f3223    linalg.yield %3 : f3224  } -> tensor<?x?xf32>25  return %0#0, %0#1, %2 : tensor<?x?xf32>, tensor<?x?xf32>, tensor<?x?xf32>26}27//      CHECK: func @multi_use_producer(28// CHECK-SAME:     %[[ARG0:[a-zA-Z0-9]+]]: tensor<?x?xf32>29// CHECK-SAME:     %[[ARG1:[a-zA-Z0-9]+]]: tensor<?x?xf32>30// CHECK-SAME:     %[[ARG2:[a-zA-Z0-9]+]]: tensor<?x?xf32>31// CHECK-SAME:     %[[ARG3:[a-zA-Z0-9]+]]: tensor<?x?xf32>32// CHECK-SAME:     %[[ARG4:[a-zA-Z0-9]+]]: tensor<?x?xf32>)33//      CHECK:   %[[RESULT:.+]]:3 = linalg.generic34//      CHECK:   return %[[RESULT]]#0, %[[RESULT]]#1, %[[RESULT]]#235