Skip to content

Commit 2e6b18b

Browse files
authored
[mlir][sparse] add example to new operation doc, and roundtrip test (#85711)
1 parent ba2dc29 commit 2e6b18b

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,9 +1444,19 @@ def SparseTensor_HasRuntimeLibraryOp
14441444
: SparseTensor_Op<"has_runtime_library", []>, Results<(outs I1:$result)> {
14451445
string summary = "Indicates whether running in runtime/codegen mode";
14461446
string description = [{
1447-
Returns a boolean value that indicates whether the sparse compiler runs in
1448-
runtime library mode or not. For testing only: This op is useful for writing
1449-
test cases that require different IR depending on runtime/codegen mode.
1447+
Returns a boolean value that indicates whether the sparsifier runs in
1448+
runtime library mode or not. For testing only! This operation is useful
1449+
for writing test cases that require different code depending on
1450+
runtime/codegen mode.
1451+
1452+
Example:
1453+
1454+
```mlir
1455+
%has_runtime = sparse_tensor.has_runtime_library
1456+
scf.if %has_runtime {
1457+
...
1458+
}
1459+
```
14501460
}];
14511461
let assemblyFormat = "attr-dict";
14521462
}

mlir/test/Dialect/SparseTensor/roundtrip.mlir

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -728,3 +728,13 @@ func.func @sparse_print(%arg0: tensor<10x10xf64, #CSR>) {
728728
sparse_tensor.print %arg0 : tensor<10x10xf64, #CSR>
729729
return
730730
}
731+
732+
// -----
733+
734+
// CHECK-LABEL: func.func @sparse_has_runtime() -> i1
735+
// CHECK: %[[H:.*]] = sparse_tensor.has_runtime_library
736+
// CHECK: return %[[H]] : i1
737+
func.func @sparse_has_runtime() -> i1 {
738+
%has_runtime = sparse_tensor.has_runtime_library
739+
return %has_runtime : i1
740+
}

0 commit comments

Comments
 (0)