[Mlir-commits] [mlir] 2e6b18b - [mlir][sparse] add example to new operation doc, and roundtrip test (#85711)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Mar 18 17:06:06 PDT 2024


Author: Aart Bik
Date: 2024-03-18T17:06:02-07:00
New Revision: 2e6b18b3f3924d150c8837175938e76c3402f83f

URL: https://github.com/llvm/llvm-project/commit/2e6b18b3f3924d150c8837175938e76c3402f83f
DIFF: https://github.com/llvm/llvm-project/commit/2e6b18b3f3924d150c8837175938e76c3402f83f.diff

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

Added: 
    

Modified: 
    mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorOps.td
    mlir/test/Dialect/SparseTensor/roundtrip.mlir

Removed: 
    


################################################################################
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 
diff erent 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 
diff erent 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
+}


        


More information about the Mlir-commits mailing list