Skip to content

Commit

Permalink
[mlir][sparse] add example to new operation doc, and roundtrip test (l…
Browse files Browse the repository at this point in the history
  • Loading branch information
aartbik authored Mar 19, 2024
1 parent ba2dc29 commit 2e6b18b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
16 changes: 13 additions & 3 deletions mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
Original file line number Diff line number Diff line change
Expand Up @@ -1444,9 +1444,19 @@ def SparseTensor_HasRuntimeLibraryOp
: SparseTensor_Op<"has_runtime_library", []>, Results<(outs I1:$result)> {
string summary = "Indicates whether running in runtime/codegen mode";
string description = [{
Returns a boolean value that indicates whether the sparse compiler runs in
runtime library mode or not. For testing only: This op is useful for writing
test cases that require different IR depending on runtime/codegen mode.
Returns a boolean value that indicates whether the sparsifier runs in
runtime library mode or not. For testing only! This operation is useful
for writing test cases that require different code depending on
runtime/codegen mode.

Example:

```mlir
%has_runtime = sparse_tensor.has_runtime_library
scf.if %has_runtime {
...
}
```
}];
let assemblyFormat = "attr-dict";
}
Expand Down
10 changes: 10 additions & 0 deletions mlir/test/Dialect/SparseTensor/roundtrip.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -728,3 +728,13 @@ func.func @sparse_print(%arg0: tensor<10x10xf64, #CSR>) {
sparse_tensor.print %arg0 : tensor<10x10xf64, #CSR>
return
}

// -----

// CHECK-LABEL: func.func @sparse_has_runtime() -> i1
// CHECK: %[[H:.*]] = sparse_tensor.has_runtime_library
// CHECK: return %[[H]] : i1
func.func @sparse_has_runtime() -> i1 {
%has_runtime = sparse_tensor.has_runtime_library
return %has_runtime : i1
}

0 comments on commit 2e6b18b

Please sign in to comment.