xref: /llvm-project/mlir/test/Dialect/SparseTensor/minipipeline_parallel.mlir (revision 8f0c014b12663129d8bfe0cc89f06e7a1d8b48c2)
1// RUN: mlir-opt %s --sparsification-and-bufferization        | FileCheck %s --check-prefix=CHECK-NOPARA
2// RUN: mlir-opt %s --sparsification-and-bufferization="parallelization-strategy=any-storage-any-loop" | FileCheck %s --check-prefix=CHECK-PARA
3
4// Test to ensure we can pass parallelization flags into
5// the mini sparsification and bufferization pipeline.
6
7#SparseMatrix = #sparse_tensor.encoding<{
8  map = (d0, d1) -> (d0 : compressed, d1 : compressed)
9}>
10
11#trait_ss = {
12  indexing_maps = [
13    affine_map<(i,j) -> (i,j)>,  // A
14    affine_map<(i,j) -> (i,j)>   // X (out)
15  ],
16  iterator_types = ["parallel", "parallel"],
17  doc = "X(i,j) = A(i,j) * SCALE"
18}
19
20//
21// CHECK-NOPARA-LABEL: func.func @scale_ss
22// CHECK-NOPARA:       scf.for
23//
24// CHECK-PARA-LABEL: func.func @scale_ss
25// CHECK-PARA:       scf.parallel
26//
27func.func @scale_ss(%scale: f32,
28               %arga: tensor<?x?xf32, #SparseMatrix>,
29	       %argx: tensor<?x?xf32>) -> tensor<?x?xf32> {
30  %0 = linalg.generic #trait_ss
31     ins(%arga: tensor<?x?xf32, #SparseMatrix>)
32    outs(%argx: tensor<?x?xf32>) {
33      ^bb(%a: f32, %x: f32):
34        %0 = arith.mulf %a, %scale : f32
35        linalg.yield %0 : f32
36  } -> tensor<?x?xf32>
37  return %0 : tensor<?x?xf32>
38}
39