Skip to content

Commit 6ada671

Browse files
aartbikAlexisPerry
authored andcommitted
[mlir][sparse] added some clarification on sparse tensors ABI (llvm#96331)
1 parent cd34316 commit 6ada671

File tree

1 file changed

+13
-1
lines changed
  • mlir/include/mlir/Dialect/SparseTensor/Transforms

1 file changed

+13
-1
lines changed

mlir/include/mlir/Dialect/SparseTensor/Transforms/Passes.td

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@ include "mlir/Pass/PassBase.td"
1414
def SparseAssembler : Pass<"sparse-assembler", "ModuleOp"> {
1515
let summary = "Add [dis]assemble operations on external sparse tensors";
1616
let description = [{
17-
A pass that converts public entry methods that use sparse tensors as
17+
Unlike dense tensors, MLIR does **not** provide a direct `_mlir_ciface_`
18+
ABI for passing sparse tensors as arguments from and to external methods
19+
(within MLIR-generated methods, sparse tensors can be freely passed
20+
around, but this eventually uses a bespoke parameter passing format
21+
that is subject to change; like opaque pointers when the sparse runtime
22+
support library is used or the constituent arrays and structs for
23+
direct IR codegen). The sparse assembler pass, however, can be used
24+
to obtain a stable `_mlir_ciface_` API for passing sparse tensors
25+
from and to an external environment, such as Python, PyTorch, or JAX.
26+
27+
The pass converts public entry methods that use sparse tensors as
1828
input parameters and/or output return values into wrapper methods
1929
that [dis]assemble the individual tensors that constitute the actual
2030
storage used externally into MLIR sparse tensors. This pass can be used
@@ -27,6 +37,8 @@ def SparseAssembler : Pass<"sparse-assembler", "ModuleOp"> {
2737
By default, the pass uses the [dis]assemble operations to input and output
2838
sparse tensors. When the direct-out option is set, however, the output
2939
directly returns the MLIR allocated buffers to the external runtime.
40+
41+
The pass should always run before the actual sparsification passes.
3042
}];
3143
let constructor = "mlir::createSparseAssembler()";
3244
let dependentDialects = [

0 commit comments

Comments
 (0)