[Mlir-commits] [mlir] 8cf60e6 - [mlir][sparse] updated setter/getter comments
Aart Bik
llvmlistbot at llvm.org
Thu Jul 8 09:36:35 PDT 2021
Author: Aart Bik
Date: 2021-07-08T09:36:22-07:00
New Revision: 8cf60e61e7b0e3213b5b81039878dcf1ef18c00f
URL: https://github.com/llvm/llvm-project/commit/8cf60e61e7b0e3213b5b81039878dcf1ef18c00f
DIFF: https://github.com/llvm/llvm-project/commit/8cf60e61e7b0e3213b5b81039878dcf1ef18c00f.diff
LOG: [mlir][sparse] updated setter/getter comments
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
Added:
Modified:
mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
Removed:
################################################################################
diff --git a/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h b/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
index d7496b30a1c3f..f2c4b3018649e 100644
--- a/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
+++ b/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h
@@ -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]; }
More information about the Mlir-commits
mailing list