diff --git a/mlir/include/mlir-c/Dialect/SparseTensor.h b/mlir/include/mlir-c/Dialect/SparseTensor.h --- a/mlir/include/mlir-c/Dialect/SparseTensor.h +++ b/mlir/include/mlir-c/Dialect/SparseTensor.h @@ -20,12 +20,10 @@ MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(SparseTensor, sparse_tensor); /// Dimension level types that define sparse tensors: -/// - MLIR_SPARSE_TENSOR_DIM_LEVEL_DENSE - dimension is dense, every +/// - MLIR_SPARSE_TENSOR_DIM_LEVEL_DENSE - dimension is dense, every /// entry is stored /// - MLIR_SPARSE_TENSOR_DIM_LEVEL_COMPRESSED - dimension is sparse, -/// only nonzeros are stored. -/// - MLIR_SPARSE_TENSOR_DIM_LEVEL_SINGLETON - dimension contains single -/// coordinate, no siblings. +/// only nonzeros are stored (no duplicates). /// /// These correspond to SparseTensorEncodingAttr::DimLevelType in the C++ API. /// If updating, keep them in sync and update the static_assert in the impl @@ -33,7 +31,6 @@ enum MlirSparseTensorDimLevelType { MLIR_SPARSE_TENSOR_DIM_LEVEL_DENSE, MLIR_SPARSE_TENSOR_DIM_LEVEL_COMPRESSED, - MLIR_SPARSE_TENSOR_DIM_LEVEL_SINGLETON, }; //===----------------------------------------------------------------------===// diff --git a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td --- a/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td +++ b/mlir/include/mlir/Dialect/SparseTensor/IR/SparseTensorAttrDefs.td @@ -84,11 +84,10 @@ let extraClassDeclaration = [{ // Dimension level types that define sparse tensors: - // Dense - dimension is dense, every entry is stored - // Compressed - dimension is sparse, only nonzeros are stored - // Singleton - dimension contains single coordinate, no siblings + // Dense - dimension is dense, every entry is stored + // Compressed (unique) - dimension is sparse, only nonzeros are stored (no duplicates) enum class DimLevelType { - Dense, Compressed, Singleton + Dense, Compressed }; }]; } diff --git a/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h b/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h --- a/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h +++ b/mlir/include/mlir/Dialect/SparseTensor/Utils/Merger.h @@ -21,7 +21,7 @@ namespace sparse_tensor { /// Dimension level type for a tensor (undef means index does not appear). -enum Dim { kSparse, kDense, kSingle, kUndef }; +enum Dim { kSparse, kDense, kUndef }; /// Tensor expression kind. enum Kind { diff --git a/mlir/lib/Bindings/Python/DialectSparseTensor.cpp b/mlir/lib/Bindings/Python/DialectSparseTensor.cpp --- a/mlir/lib/Bindings/Python/DialectSparseTensor.cpp +++ b/mlir/lib/Bindings/Python/DialectSparseTensor.cpp @@ -18,8 +18,7 @@ static void populateDialectSparseTensorSubmodule(const py::module &m) { py::enum_(m, "DimLevelType", py::module_local()) .value("dense", MLIR_SPARSE_TENSOR_DIM_LEVEL_DENSE) - .value("compressed", MLIR_SPARSE_TENSOR_DIM_LEVEL_COMPRESSED) - .value("singleton", MLIR_SPARSE_TENSOR_DIM_LEVEL_SINGLETON); + .value("compressed", MLIR_SPARSE_TENSOR_DIM_LEVEL_COMPRESSED); mlir_attribute_subclass(m, "EncodingAttr", mlirAttributeIsASparseTensorEncodingAttr) diff --git a/mlir/lib/CAPI/Dialect/SparseTensor.cpp b/mlir/lib/CAPI/Dialect/SparseTensor.cpp --- a/mlir/lib/CAPI/Dialect/SparseTensor.cpp +++ b/mlir/lib/CAPI/Dialect/SparseTensor.cpp @@ -25,9 +25,7 @@ static_cast(SparseTensorEncodingAttr::DimLevelType::Dense) && static_cast(MLIR_SPARSE_TENSOR_DIM_LEVEL_COMPRESSED) == static_cast( - SparseTensorEncodingAttr::DimLevelType::Compressed) && - static_cast(MLIR_SPARSE_TENSOR_DIM_LEVEL_SINGLETON) == - static_cast(SparseTensorEncodingAttr::DimLevelType::Singleton), + SparseTensorEncodingAttr::DimLevelType::Compressed), "MlirSparseTensorDimLevelType (C-API) and DimLevelType (C++) mismatch"); bool mlirAttributeIsASparseTensorEncodingAttr(MlirAttribute attr) { 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 @@ -71,8 +71,6 @@ dlt.push_back(SparseTensorEncodingAttr::DimLevelType::Dense); } else if (strVal == "compressed") { dlt.push_back(SparseTensorEncodingAttr::DimLevelType::Compressed); - } else if (strVal == "singleton") { - dlt.push_back(SparseTensorEncodingAttr::DimLevelType::Singleton); } else { parser.emitError(parser.getNameLoc(), "unexpected dimension level type: ") @@ -126,9 +124,6 @@ case DimLevelType::Compressed: printer << "\"compressed\""; break; - case DimLevelType::Singleton: - printer << "\"singleton\""; - break; } if (i != e - 1) printer << ", "; 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 @@ -148,8 +148,6 @@ return DimLevelType::kDense; case SparseTensorEncodingAttr::DimLevelType::Compressed: return DimLevelType::kCompressed; - case SparseTensorEncodingAttr::DimLevelType::Singleton: - return DimLevelType::kSingleton; } llvm_unreachable("Unknown SparseTensorEncodingAttr::DimLevelType"); } 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 @@ -378,11 +378,6 @@ if (alreadyCompressed) return false; // Dense after Compressed not yet supported. break; - case SparseTensorEncodingAttr::DimLevelType::Singleton: - // Although Singleton isn't generally supported yet, the direct - // conversion method doesn't have any particular problems with - // singleton after compressed. - break; } } return true; diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp --- a/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp +++ b/mlir/lib/Dialect/SparseTensor/Transforms/Sparsification.cpp @@ -147,8 +147,6 @@ SparseTensorEncodingAttr::DimLevelType tp = enc.getDimLevelType()[d]; if (tp == SparseTensorEncodingAttr::DimLevelType::Compressed) return Dim::kSparse; - if (tp == SparseTensorEncodingAttr::DimLevelType::Singleton) - return Dim::kSingle; } return Dim::kDense; } diff --git a/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp b/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp --- a/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp +++ b/mlir/lib/Dialect/SparseTensor/Utils/Merger.cpp @@ -591,9 +591,6 @@ case kDense: llvm::dbgs() << "D"; break; - case kSingle: - llvm::dbgs() << "T"; - break; case kUndef: llvm::dbgs() << "U"; break; diff --git a/mlir/test/CAPI/sparse_tensor.c b/mlir/test/CAPI/sparse_tensor.c --- a/mlir/test/CAPI/sparse_tensor.c +++ b/mlir/test/CAPI/sparse_tensor.c @@ -25,7 +25,7 @@ // clang-format off const char *originalAsm = "#sparse_tensor.encoding<{ " - "dimLevelType = [ \"dense\", \"compressed\", \"singleton\"], " + "dimLevelType = [ \"dense\", \"compressed\", \"compressed\"], " "dimOrdering = affine_map<(d0, d1, d2) -> (d0, d1, d2)>, " "pointerBitWidth = 32, indexBitWidth = 64 }>"; // clang-format on @@ -40,7 +40,7 @@ mlirAffineMapDump(dimOrdering); // CHECK: level_type: 0 // CHECK: level_type: 1 - // CHECK: level_type: 2 + // CHECK: level_type: 1 int numLevelTypes = mlirSparseTensorEncodingGetNumDimLevelTypes(originalAttr); enum MlirSparseTensorDimLevelType *levelTypes = malloc(sizeof(enum MlirSparseTensorDimLevelType) * numLevelTypes);