From f8ce460e48ccc774354df75520d00a67ddbf84c0 Mon Sep 17 00:00:00 2001 From: Aart Bik <39774503+aartbik@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:52:28 -0800 Subject: [PATCH] [mlir][sparse] cleanup sparse runtime library (#82807) remove some obsoleted APIs from the library that have been fully replaced with actual direct IR codegen --- .../mlir/Dialect/SparseTensor/IR/Enums.h | 9 ++-- .../ExecutionEngine/SparseTensor/Storage.h | 43 ++-------------- .../ExecutionEngine/SparseTensorRuntime.h | 24 +-------- .../ExecutionEngine/SparseTensor/Storage.cpp | 7 --- .../ExecutionEngine/SparseTensorRuntime.cpp | 50 ++----------------- 5 files changed, 12 insertions(+), 121 deletions(-) diff --git a/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h b/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h index a00c9c31256c..1c81d80ea7ec 100644 --- a/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h +++ b/mlir/include/mlir/Dialect/SparseTensor/IR/Enums.h @@ -145,12 +145,9 @@ constexpr bool isComplexPrimaryType(PrimaryType valTy) { /// The actions performed by @newSparseTensor. enum class Action : uint32_t { kEmpty = 0, - kEmptyForward = 1, - kFromCOO = 2, - kFromReader = 4, - kToCOO = 5, - kPack = 7, - kSortCOOInPlace = 8, + kFromReader = 1, + kPack = 2, + kSortCOOInPlace = 3, }; /// This enum defines all supported storage format without the level properties. diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h b/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h index eff1aca42d3e..fe0e08b5c840 100644 --- a/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h +++ b/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h @@ -149,13 +149,6 @@ public: MLIR_SPARSETENSOR_FOREVERY_V(DECL_GETVALUES) #undef DECL_GETVALUES - /// Element-wise forwarding insertions. The first argument is the - /// dimension-coordinates for the value being inserted. -#define DECL_FORWARDINGINSERT(VNAME, V) \ - virtual void forwardingInsert(const uint64_t *, V); - MLIR_SPARSETENSOR_FOREVERY_V(DECL_FORWARDINGINSERT) -#undef DECL_FORWARDINGINSERT - /// Element-wise insertion in lexicographic coordinate order. The first /// argument is the level-coordinates for the value being inserted. #define DECL_LEXINSERT(VNAME, V) virtual void lexInsert(const uint64_t *, V); @@ -171,9 +164,6 @@ public: MLIR_SPARSETENSOR_FOREVERY_V(DECL_EXPINSERT) #undef DECL_EXPINSERT - /// Finalizes forwarding insertions. - virtual void endForwardingInsert() = 0; - /// Finalizes lexicographic insertions. virtual void endLexInsert() = 0; @@ -248,7 +238,7 @@ public: static SparseTensorStorage
* newEmpty(uint64_t dimRank, const uint64_t *dimSizes, uint64_t lvlRank, const uint64_t *lvlSizes, const LevelType *lvlTypes, - const uint64_t *dim2lvl, const uint64_t *lvl2dim, bool forwarding); + const uint64_t *dim2lvl, const uint64_t *lvl2dim); /// Allocates a new sparse tensor and initializes it from the given COO. static SparseTensorStorage
*
@@ -284,13 +274,6 @@ public:
*out = &values;
}
- /// Partially specialize forwarding insertions based on template types.
- void forwardingInsert(const uint64_t *dimCoords, V val) final {
- assert(dimCoords && coo);
- map.pushforward(dimCoords, lvlCursor.data());
- coo->add(lvlCursor, val);
- }
-
/// Partially specialize lexicographical insertions based on template types.
void lexInsert(const uint64_t *lvlCoords, V val) final {
assert(lvlCoords);
@@ -345,21 +328,6 @@ public:
}
}
- /// Finalizes forwarding insertions.
- void endForwardingInsert() final {
- // Ensure COO is sorted.
- assert(coo);
- coo->sort();
- // Now actually insert the `elements`.
- const auto &elements = coo->getElements();
- const uint64_t nse = elements.size();
- assert(values.size() == 0);
- values.reserve(nse);
- fromCOO(elements, 0, nse, 0);
- delete coo;
- coo = nullptr;
- }
-
/// Finalizes lexicographic insertions.
void endLexInsert() final {
if (!allDense) {
@@ -653,13 +621,10 @@ template *SparseTensorStorage ::newEmpty(
uint64_t dimRank, const uint64_t *dimSizes, uint64_t lvlRank,
const uint64_t *lvlSizes, const LevelType *lvlTypes,
- const uint64_t *dim2lvl, const uint64_t *lvl2dim, bool forwarding) {
- SparseTensorCOO (dimRank, dimSizes, lvlRank, lvlSizes,
- lvlTypes, dim2lvl, lvl2dim, lvlCOO,
- !forwarding);
+ lvlTypes, dim2lvl, lvl2dim, nullptr,
+ true);
}
template ::newEmpty( \
- dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes, dim2lvl, lvl2dim, \
- false); \
- } \
- case Action::kEmptyForward: { \
- return SparseTensorStorage ::newEmpty( \
- dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes, dim2lvl, lvl2dim, \
- true); \
- } \
- case Action::kFromCOO: { \
- assert(ptr && "Received nullptr for SparseTensorCOO object"); \
- auto &coo = *static_cast ::newFromCOO( \
- dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes, dim2lvl, lvl2dim, \
- coo); \
+ dimRank, dimSizes, lvlRank, lvlSizes, lvlTypes, dim2lvl, lvl2dim); \
} \
case Action::kFromReader: { \
assert(ptr && "Received nullptr for SparseTensorReader object"); \
@@ -138,11 +125,6 @@ extern "C" {
return static_cast ( \
lvlRank, lvlSizes, lvlTypes, dim2lvl, lvl2dim)); \
} \
- case Action::kToCOO: { \
- assert(ptr && "Received nullptr for SparseTensorStorage object"); \
- auto &tensor = *static_cast