This commit is part of the migration of towards the new STEA syntax/design. In particular, this commit includes the following changes:
* Renaming compiler-internal functions/methods:
* `SparseTensorEncodingAttr::{getDimLevelType => getLvlTypes}`
* `Merger::{getDimLevelType => getLvlType}` (for consistency)
* `sparse_tensor::{getDimLevelType => buildLevelType}` (to help reduce confusion vs actual getter methods)
* Renaming external facets to match:
* the STEA parser and printer
* the C and Python bindings
* PyTACO
However, the actual renaming of the `DimLevelType` itself (along with all the "dlt" names) will be handled in a separate commit.
Reviewed By: aartbik
Differential Revision: https://reviews.llvm.org/D150330
40 lines
1.5 KiB
MLIR
40 lines
1.5 KiB
MLIR
// RUN: mlir-opt %s -sparsification | FileCheck %s
|
|
|
|
|
|
// The file contains examples that will be rejected by sparse compiler
|
|
// (we expect the linalg.generic unchanged).
|
|
#SparseVector = #sparse_tensor.encoding<{lvlTypes = ["compressed"]}>
|
|
|
|
#trait = {
|
|
indexing_maps = [
|
|
affine_map<(i) -> (i)>, // a (in)
|
|
affine_map<(i) -> ()> // x (out)
|
|
],
|
|
iterator_types = ["reduction"]
|
|
}
|
|
|
|
// CHECK-LABEL: func.func @sparse_reduction_subi(
|
|
// CHECK-SAME: %[[VAL_0:.*]]: tensor<i32>,
|
|
// CHECK-SAME: %[[VAL_1:.*]]: tensor<?xi32, #sparse_tensor.encoding<{ lvlTypes = [ "compressed" ] }>>) -> tensor<i32> {
|
|
// CHECK: %[[VAL_2:.*]] = linalg.generic
|
|
// CHECK: ^bb0(%[[VAL_3:.*]]: i32, %[[VAL_4:.*]]: i32):
|
|
// CHECK: %[[VAL_5:.*]] = arith.subi %[[VAL_3]], %[[VAL_4]] : i32
|
|
// CHECK: linalg.yield %[[VAL_5]] : i32
|
|
// CHECK: } -> tensor<i32>
|
|
// CHECK: return %[[VAL_6:.*]] : tensor<i32>
|
|
func.func @sparse_reduction_subi(%argx: tensor<i32>,
|
|
%arga: tensor<?xi32, #SparseVector>)
|
|
-> tensor<i32> {
|
|
%0 = linalg.generic #trait
|
|
ins(%arga: tensor<?xi32, #SparseVector>)
|
|
outs(%argx: tensor<i32>) {
|
|
^bb(%a: i32, %x: i32):
|
|
// NOTE: `subi %a, %x` is the reason why the program is rejected by the sparse compiler.
|
|
// It is because we do not allow `-outTensor` in reduction loops as it creates cyclic
|
|
// dependences.
|
|
%t = arith.subi %a, %x: i32
|
|
linalg.yield %t : i32
|
|
} -> tensor<i32>
|
|
return %0 : tensor<i32>
|
|
}
|