[Mlir-commits] [mlir] [mlir][sparse] remove obsoleted output methods from runtime (PR #70523)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Oct 27 16:51:01 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-mlir

Author: Aart Bik (aartbik)

<details>
<summary>Changes</summary>

Our CODE and LIB are more unified every day!

---
Full diff: https://github.com/llvm/llvm-project/pull/70523.diff


3 Files Affected:

- (modified) mlir/include/mlir/ExecutionEngine/SparseTensor/File.h (+2-29) 
- (modified) mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h (-7) 
- (modified) mlir/lib/ExecutionEngine/SparseTensorRuntime.cpp (-11) 


``````````diff
diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h b/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h
index 1b5f0553a3af959..85bbfe06a86a020 100644
--- a/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h
+++ b/mlir/include/mlir/ExecutionEngine/SparseTensor/File.h
@@ -1,4 +1,4 @@
-//===- File.h - Reading/writing sparse tensors from/to files ----*- C++ -*-===//
+//===- File.h - Reading sparse tensors from files --------------*- C++ -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===----------------------------------------------------------------------===//
 //
-// This file implements reading and writing sparse tensor files in one of the
+// This file implements reading sparse tensor from files in one of the
 // following external formats:
 //
 // (1) Matrix Market Exchange (MME): *.mtx
@@ -358,33 +358,6 @@ bool SparseTensorReader::readToBuffersLoop(const MapRef &map, C *lvlCoordinates,
   return isSorted;
 }
 
-/// Writes the sparse tensor to `filename` in extended FROSTT format.
-template <typename V>
-inline void writeExtFROSTT(const SparseTensorCOO<V> &coo,
-                           const char *filename) {
-  assert(filename && "Got nullptr for filename");
-  const auto &dimSizes = coo.getDimSizes();
-  const auto &elements = coo.getElements();
-  const uint64_t dimRank = coo.getRank();
-  const uint64_t nse = elements.size();
-  std::fstream file;
-  file.open(filename, std::ios_base::out | std::ios_base::trunc);
-  assert(file.is_open());
-  file << "; extended FROSTT format\n" << dimRank << " " << nse << std::endl;
-  for (uint64_t d = 0; d < dimRank - 1; ++d)
-    file << dimSizes[d] << " ";
-  file << dimSizes[dimRank - 1] << std::endl;
-  for (uint64_t i = 0; i < nse; ++i) {
-    const auto &coords = elements[i].coords;
-    for (uint64_t d = 0; d < dimRank; ++d)
-      file << (coords[d] + 1) << " ";
-    file << elements[i].value << std::endl;
-  }
-  file.flush();
-  file.close();
-  assert(file.good());
-}
-
 } // namespace sparse_tensor
 } // namespace mlir
 
diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h b/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h
index bbfe6ed19e70da3..0eb0590ac7e5747 100644
--- a/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h
+++ b/mlir/include/mlir/ExecutionEngine/SparseTensorRuntime.h
@@ -166,13 +166,6 @@ MLIR_CRUNNERUTILS_EXPORT void endForwardingInsert(void *tensor);
 /// Tensor-storage method to finalize lexicographic insertions.
 MLIR_CRUNNERUTILS_EXPORT void endLexInsert(void *tensor);
 
-/// Coordinate-scheme method to write to file in extended FROSTT format.
-#define DECL_OUTSPARSETENSOR(VNAME, V)                                         \
-  MLIR_CRUNNERUTILS_EXPORT void outSparseTensor##VNAME(void *coo, void *dest,  \
-                                                       bool sort);
-MLIR_SPARSETENSOR_FOREVERY_V(DECL_OUTSPARSETENSOR)
-#undef DECL_OUTSPARSETENSOR
-
 /// Releases the memory for the tensor-storage object.
 MLIR_CRUNNERUTILS_EXPORT void delSparseTensor(void *tensor);
 
diff --git a/mlir/lib/ExecutionEngine/SparseTensorRuntime.cpp b/mlir/lib/ExecutionEngine/SparseTensorRuntime.cpp
index 441a6094eddf06a..f84fdd3964c14f1 100644
--- a/mlir/lib/ExecutionEngine/SparseTensorRuntime.cpp
+++ b/mlir/lib/ExecutionEngine/SparseTensorRuntime.cpp
@@ -496,17 +496,6 @@ void endLexInsert(void *tensor) {
   return static_cast<SparseTensorStorageBase *>(tensor)->endLexInsert();
 }
 
-#define IMPL_OUTSPARSETENSOR(VNAME, V)                                         \
-  void outSparseTensor##VNAME(void *coo, void *dest, bool sort) {              \
-    assert(coo);                                                               \
-    auto &coo_ = *static_cast<SparseTensorCOO<V> *>(coo);                      \
-    if (sort)                                                                  \
-      coo_.sort();                                                             \
-    return writeExtFROSTT(coo_, static_cast<char *>(dest));                    \
-  }
-MLIR_SPARSETENSOR_FOREVERY_V(IMPL_OUTSPARSETENSOR)
-#undef IMPL_OUTSPARSETENSOR
-
 void delSparseTensor(void *tensor) {
   delete static_cast<SparseTensorStorageBase *>(tensor);
 }

``````````

</details>


https://github.com/llvm/llvm-project/pull/70523


More information about the Mlir-commits mailing list