brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.6 KiB · d335e9c Raw
61 lines · plain
1// RUN: mlir-opt --transform-interpreter --cse --split-input-file --mlir-print-local-scope %s | FileCheck %s2 3module {4  func.func @generic_parallel(%arg0 : tensor<?x?xf32>, %arg1 : tensor<?xf32>) -> tensor<?x?xf32> {5    %c0 = arith.constant 0 : index6    %c1 = arith.constant 1 : index7    %d0 = tensor.dim %arg0, %c0 : tensor<?x?xf32>8    %d1 = tensor.dim %arg0, %c1 : tensor<?x?xf32>9    %empty = tensor.empty(%d0, %d1) : tensor<?x?xf32>10    %generic = linalg.generic {11        indexing_maps = [affine_map<(d0, d1) -> (d0, d1)>,12                         affine_map<(d0, d1) -> (d1)>,13                         affine_map<(d0, d1) -> (d0, d1)>],14        iterator_types = ["parallel", "parallel"]}15        ins(%arg0, %arg1 : tensor<?x?xf32>, tensor<?xf32>) outs(%empty : tensor<?x?xf32>) {16      ^bb(%b0 : f32, %b1 : f32, %b2 : f32):17        %add = arith.addf %b0, %b1 : f3218        linalg.yield %add : f3219    } -> tensor<?x?xf32>20    return %generic : tensor<?x?xf32>21  }22}23 24module attributes {transform.with_named_sequence} {25  transform.named_sequence @__transform_main(%arg1 : !transform.any_op {transform.readonly}) {26    %op = transform.structured.match ops {["linalg.generic"]} in %arg127        : (!transform.any_op) -> !transform.any_op28    %tiled_op, %loop = transform.test.tile_using_custom_loop %op tile_sizes = [10, 20]29        : (!transform.any_op) -> (!transform.any_op, !transform.any_op)30    transform.yield31  }32}33// CHECK-LABEL: func @generic_parallel34//  CHECK-SAME:     %[[ARG0:[a-zA-Z0-9]+]]: tensor<?x?xf32>35//  CHECK-SAME:     %[[ARG1:.+]]: tensor<?xf32>36//   CHECK-DAG:   %[[C0:.+]] = arith.constant 0 : index37//   CHECK-DAG:   %[[C1:.+]] = arith.constant 1 : index38//   CHECK-DAG:   %[[D0:.+]] = tensor.dim %[[ARG0]], %[[C0]]39//   CHECK-DAG:   %[[D1:.+]] = tensor.dim %[[ARG0]], %[[C1]]40//   CHECK-DAG:   %[[EMPTY:.+]] = tensor.empty(%[[D0]], %[[D1]]) : tensor<?x?xf32>41//   CHECK-DAG:   %[[NITERS0:.+]] = affine.apply affine_map<()[s0] -> (s0 ceildiv 10)>()[%[[D0]]]42//   CHECK-DAG:   %[[NITERS1:.+]] = affine.apply affine_map<()[s0] -> (s0 ceildiv 20)>()[%[[D1]]]43//   CHECK-DAG:   %[[NITERS:.+]] = affine.apply affine_map<()[s0, s1] -> ((s0 ceildiv 10) * (s1 ceildiv 20))>()[%[[D0]], %[[D1]]]44//       CHECK:   %[[FOR:.+]] = scf.for %[[IV:[a-zA-Z0-9]+]] = %[[C0]] to %[[NITERS]] step %[[C1]]45//  CHECK-SAME:       iter_args(%[[INIT:.+]] = %[[EMPTY]])46//       CHECK:     %[[DELINEARIZE:.+]]:2 = affine.delinearize_index %[[IV]] into (%[[NITERS0]], %[[NITERS1]])47//   CHECK-DAG:     %[[SIZE0:.+]] = affine.min affine_map<(d0)[s0] -> (d0 * -10 + s0, 10)>(%[[DELINEARIZE]]#0)[%[[D0]]]48//   CHECK-DAG:     %[[SIZE1:.+]] = affine.min affine_map<(d0)[s0] -> (d0 * -20 + s0, 20)>(%[[DELINEARIZE]]#1)[%[[D1]]]49//   CHECK-DAG:     %[[OFFSET0:.+]] = affine.apply affine_map<(d0) -> (d0 * 10)>(%[[DELINEARIZE]]#0)50//   CHECK-DAG:     %[[OFFSET1:.+]] = affine.apply affine_map<(d0) -> (d0 * 20)>(%[[DELINEARIZE]]#1)51//   CHECK-DAG:     %[[ARG0_SLICE:.+]] = tensor.extract_slice %[[ARG0]][%[[OFFSET0]], %[[OFFSET1]]] [%[[SIZE0]], %[[SIZE1]]] [1, 1]52//   CHECK-DAG:     %[[ARG1_SLICE:.+]] = tensor.extract_slice %[[ARG1]][%[[OFFSET1]]] [%[[SIZE1]]] [1]53//   CHECK-DAG:     %[[INIT_SLICE:.+]] = tensor.extract_slice %[[INIT]][%[[OFFSET0]], %[[OFFSET1]]] [%[[SIZE0]], %[[SIZE1]]] [1, 1]54//       CHECK:     %[[GENERIC:.+]] = linalg.generic55//  CHECK-SAME:         ins(%[[ARG0_SLICE]], %[[ARG1_SLICE]] :56//  CHECK-SAME:         outs(%[[INIT_SLICE]] :57//       CHECK:     %[[INSERT_SLICE:.+]] = tensor.insert_slice %[[GENERIC]] into %[[INIT]]58//  CHECK-SAME:         [%[[OFFSET0]], %[[OFFSET1]]] [%[[SIZE0]], %[[SIZE1]]] [1, 1]59//       CHECK:     scf.yield %[[INSERT_SLICE]]60//       CHECK:   return %[[FOR]]61