[Mlir-commits] [mlir] [mlir][sparse] add example to new operation doc, and roundtrip test (PR #85711)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Mon Mar 18 15:36:50 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir
@llvm/pr-subscribers-mlir-sparse
Author: Aart Bik (aartbik)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/85711.diff
2 Files Affected:
- (modified) mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td (+13-3)
- (modified) mlir/test/Dialect/SparseTensor/roundtrip.mlir (+10)
``````````diff
diff --git a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
index 1b2981ac751f3e..29cf8c32447ecf 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
+++ b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
@@ -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";
}
diff --git a/mlir/test/Dialect/SparseTensor/roundtrip.mlir b/mlir/test/Dialect/SparseTensor/roundtrip.mlir
index e9e458e805ba47..a47a3d5119f96d 100644
--- a/mlir/test/Dialect/SparseTensor/roundtrip.mlir
+++ b/mlir/test/Dialect/SparseTensor/roundtrip.mlir
@@ -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
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/85711
More information about the Mlir-commits
mailing list