[Mlir-commits] [mlir] dd0d5ac - [mlir][sparse] remove redundant template parameter (NFC)
Peiming Liu
llvmlistbot at llvm.org
Mon Jan 9 11:01:43 PST 2023
Author: Peiming Liu
Date: 2023-01-09T19:01:37Z
New Revision: dd0d5acfa67afd5e7acbb87430cd42aa0ac8ea51
URL: https://github.com/llvm/llvm-project/commit/dd0d5acfa67afd5e7acbb87430cd42aa0ac8ea51
DIFF: https://github.com/llvm/llvm-project/commit/dd0d5acfa67afd5e7acbb87430cd42aa0ac8ea51.diff
LOG: [mlir][sparse] remove redundant template parameter (NFC)
The template parameter is no longer needed after MutSparseTensorDescriptor
is implemented as a subclass of SparseTensorDescriptorImpl. The only purpose
for it was to enable SFINAE.
Reviewed By: bixia
Differential Revision: https://reviews.llvm.org/D141303
Added:
Modified:
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.h
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.h b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.h
index be7e44a54c678..8d25ba2160e44 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.h
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorStorageLayout.h
@@ -188,12 +188,14 @@ class SparseTensorSpecifier {
/*implicit*/ operator Value() { return specifier; }
Value getSpecifierField(OpBuilder &builder, Location loc,
- StorageSpecifierKind kind, Optional<unsigned> dim);
+ StorageSpecifierKind kind,
+ std::optional<unsigned> dim);
void setSpecifierField(OpBuilder &builder, Location loc, Value v,
- StorageSpecifierKind kind, Optional<unsigned> dim);
+ StorageSpecifierKind kind,
+ std::optional<unsigned> dim);
- Type getFieldType(StorageSpecifierKind kind, Optional<unsigned> dim) {
+ Type getFieldType(StorageSpecifierKind kind, std::optional<unsigned> dim) {
return specifier.getType().getFieldType(kind, dim);
}
@@ -240,7 +242,7 @@ class SparseTensorDescriptorImpl {
public:
unsigned getMemRefFieldIndex(SparseTensorFieldKind kind,
- Optional<unsigned> dim) const {
+ std::optional<unsigned> dim) const {
// Delegates to storage layout.
StorageLayout<mut> layout(getSparseTensorEncoding(rType));
return layout.getMemRefFieldIndex(kind, dim);
@@ -266,7 +268,7 @@ class SparseTensorDescriptorImpl {
Value getSpecifierField(OpBuilder &builder, Location loc,
StorageSpecifierKind kind,
- Optional<unsigned> dim) const {
+ std::optional<unsigned> dim) const {
SparseTensorSpecifier md(fields.back());
return md.getSpecifierField(builder, loc, kind, dim);
}
@@ -288,7 +290,7 @@ class SparseTensorDescriptorImpl {
}
Value getMemRefField(SparseTensorFieldKind kind,
- Optional<unsigned> dim) const {
+ std::optional<unsigned> dim) const {
return fields[getMemRefFieldIndex(kind, dim)];
}
@@ -309,7 +311,7 @@ class SparseTensorDescriptorImpl {
}
Type getMemRefElementType(SparseTensorFieldKind kind,
- Optional<unsigned> dim) const {
+ std::optional<unsigned> dim) const {
return getMemRefField(kind, dim)
.getType()
.template cast<MemRefType>()
@@ -353,34 +355,30 @@ class MutSparseTensorDescriptor : public SparseTensorDescriptorImpl<true> {
/// MutSparseTensorDescriptor).
///
- template <typename T = Value>
- void setMemRefField(SparseTensorFieldKind kind, Optional<unsigned> dim, T v) {
+ void setMemRefField(SparseTensorFieldKind kind, std::optional<unsigned> dim,
+ Value v) {
fields[getMemRefFieldIndex(kind, dim)] = v;
}
- template <typename T = Value>
- void setMemRefField(unsigned fidx, T v) {
+ void setMemRefField(unsigned fidx, Value v) {
assert(fidx < fields.size() - 1);
fields[fidx] = v;
}
- template <typename T = Value>
- void setField(unsigned fidx, T v) {
+ void setField(unsigned fidx, Value v) {
assert(fidx < fields.size());
fields[fidx] = v;
}
- template <typename T = Value>
void setSpecifierField(OpBuilder &builder, Location loc,
- StorageSpecifierKind kind, Optional<unsigned> dim,
- T v) {
+ StorageSpecifierKind kind, std::optional<unsigned> dim,
+ Value v) {
SparseTensorSpecifier md(fields.back());
md.setSpecifierField(builder, loc, v, kind, dim);
fields.back() = md;
}
- template <typename T = Value>
- void setDimSize(OpBuilder &builder, Location loc, unsigned dim, T v) {
+ void setDimSize(OpBuilder &builder, Location loc, unsigned dim, Value v) {
setSpecifierField(builder, loc, StorageSpecifierKind::DimSize, dim, v);
}
More information about the Mlir-commits
mailing list