-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
[mlir][sparse] cleanup of COO #69239
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Moves typedef to only file where it is used. Removes some deadcode. Some minor doc changes.
@llvm/pr-subscribers-mlir @llvm/pr-subscribers-mlir-sparse Author: Aart Bik (aartbik) ChangesMoves typedef to only file where it is used. Full diff: https://github.com/llvm/llvm-project/pull/69239.diff 2 Files Affected:
diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensor/COO.h b/mlir/include/mlir/ExecutionEngine/SparseTensor/COO.h
index f6eb45defcc1cfd..721e9bc69adac20 100644
--- a/mlir/include/mlir/ExecutionEngine/SparseTensor/COO.h
+++ b/mlir/include/mlir/ExecutionEngine/SparseTensor/COO.h
@@ -58,21 +58,13 @@ struct ElementLT final {
const uint64_t rank;
};
-/// The type of callback functions which receive an element.
-template <typename V>
-using ElementConsumer =
- const std::function<void(const std::vector<uint64_t> &, V)> &;
-
/// A memory-resident sparse tensor in coordinate-scheme representation
-/// (a collection of `Element`s). This data structure is used as
-/// an intermediate representation; e.g., for reading sparse tensors
-/// from external formats into memory, or for certain conversions between
-/// different `SparseTensorStorage` formats.
+/// (a collection of `Element`s). This data structure is used as an
+/// intermediate representation, e.g., for reading sparse tensors from
+/// external formats into memory.
template <typename V>
class SparseTensorCOO final {
public:
- using const_iterator = typename std::vector<Element<V>>::const_iterator;
-
/// Constructs a new coordinate-scheme sparse tensor with the given
/// sizes and an optional initial storage capacity.
explicit SparseTensorCOO(const std::vector<uint64_t> &dimSizes,
@@ -106,7 +98,7 @@ class SparseTensorCOO final {
/// Returns the `operator<` closure object for the COO's element type.
ElementLT<V> getElementLT() const { return ElementLT<V>(getRank()); }
- /// Adds an element to the tensor. This method invalidates all iterators.
+ /// Adds an element to the tensor.
void add(const std::vector<uint64_t> &dimCoords, V val) {
const uint64_t *base = coordinates.data();
const uint64_t size = coordinates.size();
@@ -135,12 +127,9 @@ class SparseTensorCOO final {
elements.push_back(addedElem);
}
- const_iterator begin() const { return elements.cbegin(); }
- const_iterator end() const { return elements.cend(); }
-
/// Sorts elements lexicographically by coordinates. If a coordinate
/// is mapped to multiple values, then the relative order of those
- /// values is unspecified. This method invalidates all iterators.
+ /// values is unspecified.
void sort() {
if (isSorted)
return;
diff --git a/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h b/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
index 5e57facaf2376f6..c5be3d1acc33783 100644
--- a/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
+++ b/mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h
@@ -37,6 +37,11 @@
namespace mlir {
namespace sparse_tensor {
+/// The type of callback functions which receive an element.
+template <typename V>
+using ElementConsumer =
+ const std::function<void(const std::vector<uint64_t> &, V)> &;
+
// Forward references.
template <typename V>
class SparseTensorEnumeratorBase;
|
yinying-lisa-li
approved these changes
Oct 16, 2023
PeimingLiu
approved these changes
Oct 16, 2023
Guzhu-AMD
pushed a commit
to GPUOpen-Drivers/llvm-project
that referenced
this pull request
Oct 20, 2023
Local branch amd-gfx 6fa5d28 Merged main:6ade5183232d into amd-gfx:d5105ae3c5a9 Remote branch main b3fbb67 [mlir][sparse] cleanup of COO (llvm#69239)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Moves typedef to only file where it is used.
Removes some deadcode. Some minor doc changes.