Skip to content

Commit

Permalink
[mlir][sparse] updated setter/getter comments
Browse files Browse the repository at this point in the history
For the getters, it is bad practice to keep the reference
around for too long, as explained in the new comment

Reviewed By: gussmith23

Differential Revision: https://reviews.llvm.org/D105599
  • Loading branch information
aartbik committed Jul 8, 2021
1 parent 74a5760 commit 8cf60e6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
Expand Up @@ -168,10 +168,13 @@ class Merger {
/// Returns true if any set bit corresponds to queried dim.
bool hasAnyDimOf(const llvm::BitVector &bits, Dim d) const;

/// Setter
/// Dimension setter.
void setDim(unsigned t, unsigned i, Dim d) { dims[t][i] = d; }

/// Getters.
/// Convenience getters to immediately access the stored nodes.
/// Typically it is inadvisible to keep the reference around, as in
/// "TensorExpr &te = merger.exp(e))", since insertions into the merger
/// may cause data movement and invalidate the underlying memory address.
TensorExp &exp(unsigned e) { return tensorExps[e]; }
LatPoint &lat(unsigned l) { return latPoints[l]; }
SmallVector<unsigned, 16> &set(unsigned s) { return latSets[s]; }
Expand Down

0 comments on commit 8cf60e6

Please sign in to comment.