Skip to content

[mlir][sparse] add example to new operation doc, and roundtrip test #85711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}