diff --git a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h --- a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h +++ b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensor.h @@ -46,8 +46,7 @@ // And therefore all functions calling it cannot be constexpr either. // TODO: since Clang does allow these to be constexpr, perhaps we should // define a macro to abstract over `inline` vs `constexpr` annotations. -inline DimLevelType getDimLevelType(const SparseTensorEncodingAttr &enc, - uint64_t d) { +inline DimLevelType getDimLevelType(SparseTensorEncodingAttr enc, uint64_t d) { if (enc) { auto types = enc.getDimLevelType(); assert(d < types.size() && "Dimension out of bounds"); @@ -110,8 +109,8 @@ // Reordering. // -uint64_t toOrigDim(const SparseTensorEncodingAttr &enc, uint64_t d); -uint64_t toStoredDim(const SparseTensorEncodingAttr &enc, uint64_t d); +uint64_t toOrigDim(SparseTensorEncodingAttr enc, uint64_t d); +uint64_t toStoredDim(SparseTensorEncodingAttr enc, uint64_t d); /// Convenience method to translate the given stored dimension /// to the original dimension (0 <= d < rank). diff --git a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp --- a/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp +++ b/mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp @@ -294,7 +294,7 @@ return isUniqueDim(tp, tp.getRank() - 1); } -uint64_t mlir::sparse_tensor::toOrigDim(const SparseTensorEncodingAttr &enc, +uint64_t mlir::sparse_tensor::toOrigDim(SparseTensorEncodingAttr enc, uint64_t d) { if (enc) { auto order = enc.getDimOrdering(); @@ -306,7 +306,7 @@ return d; } -uint64_t mlir::sparse_tensor::toStoredDim(const SparseTensorEncodingAttr &enc, +uint64_t mlir::sparse_tensor::toStoredDim(SparseTensorEncodingAttr enc, uint64_t d) { if (enc) { auto order = enc.getDimOrdering(); diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.h b/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.h --- a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.h +++ b/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.h @@ -48,18 +48,16 @@ Type getOverheadType(Builder &builder, OverheadType ot); /// Returns the OverheadType for pointer overhead storage. -OverheadType pointerOverheadTypeEncoding(const SparseTensorEncodingAttr &enc); +OverheadType pointerOverheadTypeEncoding(SparseTensorEncodingAttr enc); /// Returns the OverheadType for index overhead storage. -OverheadType indexOverheadTypeEncoding(const SparseTensorEncodingAttr &enc); +OverheadType indexOverheadTypeEncoding(SparseTensorEncodingAttr enc); /// Returns the mlir::Type for pointer overhead storage. -Type getPointerOverheadType(Builder &builder, - const SparseTensorEncodingAttr &enc); +Type getPointerOverheadType(Builder &builder, SparseTensorEncodingAttr enc); /// Returns the mlir::Type for index overhead storage. -Type getIndexOverheadType(Builder &builder, - const SparseTensorEncodingAttr &enc); +Type getIndexOverheadType(Builder &builder, SparseTensorEncodingAttr enc); /// Convert OverheadType to its function-name suffix. StringRef overheadTypeFunctionSuffix(OverheadType ot); @@ -281,14 +279,14 @@ /// Generates a constant of the internal type-encoding for pointer /// overhead storage. inline Value constantPointerTypeEncoding(OpBuilder &builder, Location loc, - const SparseTensorEncodingAttr &enc) { + SparseTensorEncodingAttr enc) { return constantOverheadTypeEncoding(builder, loc, enc.getPointerBitWidth()); } /// Generates a constant of the internal type-encoding for index overhead /// storage. inline Value constantIndexTypeEncoding(OpBuilder &builder, Location loc, - const SparseTensorEncodingAttr &enc) { + SparseTensorEncodingAttr enc) { return constantOverheadTypeEncoding(builder, loc, enc.getIndexBitWidth()); } diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/CodegenUtils.cpp @@ -880,23 +880,23 @@ llvm_unreachable("Unknown OverheadType"); } -OverheadType mlir::sparse_tensor::pointerOverheadTypeEncoding( - const SparseTensorEncodingAttr &enc) { +OverheadType +mlir::sparse_tensor::pointerOverheadTypeEncoding(SparseTensorEncodingAttr enc) { return overheadTypeEncoding(enc.getPointerBitWidth()); } -OverheadType mlir::sparse_tensor::indexOverheadTypeEncoding( - const SparseTensorEncodingAttr &enc) { +OverheadType +mlir::sparse_tensor::indexOverheadTypeEncoding(SparseTensorEncodingAttr enc) { return overheadTypeEncoding(enc.getIndexBitWidth()); } -Type mlir::sparse_tensor::getPointerOverheadType( - Builder &builder, const SparseTensorEncodingAttr &enc) { +Type mlir::sparse_tensor::getPointerOverheadType(Builder &builder, + SparseTensorEncodingAttr enc) { return getOverheadType(builder, pointerOverheadTypeEncoding(enc)); } -Type mlir::sparse_tensor::getIndexOverheadType( - Builder &builder, const SparseTensorEncodingAttr &enc) { +Type mlir::sparse_tensor::getIndexOverheadType(Builder &builder, + SparseTensorEncodingAttr enc) { return getOverheadType(builder, indexOverheadTypeEncoding(enc)); } diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorConversion.cpp @@ -84,7 +84,7 @@ /// Looks up a level-size by returning a statically-computed constant /// (when possible), or by calling `genLvlSizeCall` (when dynamic). static Value createOrFoldLvlCall(OpBuilder &builder, Location loc, - SparseTensorEncodingAttr &enc, ShapedType stp, + SparseTensorEncodingAttr enc, ShapedType stp, Value tensor, unsigned lvl) { // Only sparse tensors have "levels" to query. assert(enc); @@ -111,7 +111,7 @@ /// of sparse tensors) or `linalg::createOrFoldDimOp` (for dynamic sizes /// of dense tensors). static Value createOrFoldDimCall(OpBuilder &builder, Location loc, - SparseTensorEncodingAttr &enc, ShapedType stp, + SparseTensorEncodingAttr enc, ShapedType stp, Value tensor, unsigned dim) { auto s = stp.getShape()[dim]; if (s != ShapedType::kDynamic) @@ -123,7 +123,7 @@ /// Populates the array with the dimension-sizes of the given tensor. static void fillDimSizes(OpBuilder &builder, Location loc, - SparseTensorEncodingAttr &enc, ShapedType stp, + SparseTensorEncodingAttr enc, ShapedType stp, Value tensor, SmallVectorImpl &out) { unsigned dimRank = stp.getRank(); out.reserve(dimRank); @@ -133,7 +133,7 @@ /// Returns an array with the dimension-sizes of the given tensor. static SmallVector getDimSizes(OpBuilder &builder, Location loc, - SparseTensorEncodingAttr &enc, + SparseTensorEncodingAttr enc, ShapedType stp, Value tensor) { SmallVector out; fillDimSizes(builder, loc, enc, stp, tensor, out);