1// RUN: mlir-opt %s -sparsification | FileCheck %s 2 3 4// The file contains examples that will be rejected by sparsifier 5// (we expect the linalg.generic unchanged). 6#SparseVector = #sparse_tensor.encoding<{map = (d0) -> (d0 : compressed)}> 7 8#trait = { 9 indexing_maps = [ 10 affine_map<(i) -> (i)>, // a (in) 11 affine_map<(i) -> ()> // x (out) 12 ], 13 iterator_types = ["reduction"] 14} 15 16// CHECK-LABEL: func.func @sparse_reduction_subi( 17// CHECK-SAME: %[[VAL_0:.*]]: tensor<i32>, 18// CHECK-SAME: %[[VAL_1:.*]]: tensor<?xi32, #sparse{{[0-9]*}}>) -> tensor<i32> { 19// CHECK: %[[VAL_2:.*]] = linalg.generic 20// CHECK: ^bb0(%[[VAL_3:.*]]: i32, %[[VAL_4:.*]]: i32): 21// CHECK: %[[VAL_5:.*]] = arith.subi %[[VAL_3]], %[[VAL_4]] : i32 22// CHECK: linalg.yield %[[VAL_5]] : i32 23// CHECK: } -> tensor<i32> 24// CHECK: return %[[VAL_6:.*]] : tensor<i32> 25func.func @sparse_reduction_subi(%argx: tensor<i32>, 26 %arga: tensor<?xi32, #SparseVector>) 27 -> tensor<i32> { 28 %0 = linalg.generic #trait 29 ins(%arga: tensor<?xi32, #SparseVector>) 30 outs(%argx: tensor<i32>) { 31 ^bb(%a: i32, %x: i32): 32 // NOTE: `subi %a, %x` is the reason why the program is rejected by the sparsifier. 33 // It is because we do not allow `-outTensor` in reduction loops as it creates cyclic 34 // dependences. 35 %t = arith.subi %a, %x: i32 36 linalg.yield %t : i32 37 } -> tensor<i32> 38 return %0 : tensor<i32> 39} 40