Skip to content

Commit b3fbb67

Browse files
authored
[mlir][sparse] cleanup of COO (llvm#69239)
Moves typedef to only file where it is used. Removes some deadcode. Some minor doc changes.
1 parent d9568bd commit b3fbb67

File tree

2 files changed

+10
-16
lines changed

2 files changed

+10
-16
lines changed

mlir/include/mlir/ExecutionEngine/SparseTensor/COO.h

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,13 @@ struct ElementLT final {
5858
const uint64_t rank;
5959
};
6060

61-
/// The type of callback functions which receive an element.
62-
template <typename V>
63-
using ElementConsumer =
64-
const std::function<void(const std::vector<uint64_t> &, V)> &;
65-
6661
/// A memory-resident sparse tensor in coordinate-scheme representation
67-
/// (a collection of `Element`s). This data structure is used as
68-
/// an intermediate representation; e.g., for reading sparse tensors
69-
/// from external formats into memory, or for certain conversions between
70-
/// different `SparseTensorStorage` formats.
62+
/// (a collection of `Element`s). This data structure is used as an
63+
/// intermediate representation, e.g., for reading sparse tensors from
64+
/// external formats into memory.
7165
template <typename V>
7266
class SparseTensorCOO final {
7367
public:
74-
using const_iterator = typename std::vector<Element<V>>::const_iterator;
75-
7668
/// Constructs a new coordinate-scheme sparse tensor with the given
7769
/// sizes and an optional initial storage capacity.
7870
explicit SparseTensorCOO(const std::vector<uint64_t> &dimSizes,
@@ -106,7 +98,7 @@ class SparseTensorCOO final {
10698
/// Returns the `operator<` closure object for the COO's element type.
10799
ElementLT<V> getElementLT() const { return ElementLT<V>(getRank()); }
108100

109-
/// Adds an element to the tensor. This method invalidates all iterators.
101+
/// Adds an element to the tensor.
110102
void add(const std::vector<uint64_t> &dimCoords, V val) {
111103
const uint64_t *base = coordinates.data();
112104
const uint64_t size = coordinates.size();
@@ -135,12 +127,9 @@ class SparseTensorCOO final {
135127
elements.push_back(addedElem);
136128
}
137129

138-
const_iterator begin() const { return elements.cbegin(); }
139-
const_iterator end() const { return elements.cend(); }
140-
141130
/// Sorts elements lexicographically by coordinates. If a coordinate
142131
/// is mapped to multiple values, then the relative order of those
143-
/// values is unspecified. This method invalidates all iterators.
132+
/// values is unspecified.
144133
void sort() {
145134
if (isSorted)
146135
return;

mlir/include/mlir/ExecutionEngine/SparseTensor/Storage.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
namespace mlir {
3838
namespace sparse_tensor {
3939

40+
/// The type of callback functions which receive an element.
41+
template <typename V>
42+
using ElementConsumer =
43+
const std::function<void(const std::vector<uint64_t> &, V)> &;
44+
4045
// Forward references.
4146
template <typename V>
4247
class SparseTensorEnumeratorBase;

0 commit comments

Comments
 (0)