[Mlir-commits] [mlir] cf7906c - [mlir][sparse] Fix getUnorderedCOOFromType for rank 1 tensor.
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Thu Oct 20 16:33:06 PDT 2022
Author: bixia1
Date: 2022-10-20T16:33:01-07:00
New Revision: cf7906cbbdd50cc414c1df40f149c3aaf7a56cba
URL: https://github.com/llvm/llvm-project/commit/cf7906cbbdd50cc414c1df40f149c3aaf7a56cba
DIFF: https://github.com/llvm/llvm-project/commit/cf7906cbbdd50cc414c1df40f149c3aaf7a56cba.diff
LOG: [mlir][sparse] Fix getUnorderedCOOFromType for rank 1 tensor.
Previously, it used DimLevelType::SingletonNo to represent an unorder COO
tensor of rank 1 while it should use DimLevelType::CompressedNuNo.
Reviewed By: Peiming, wrengr
Differential Revision: https://reviews.llvm.org/D136387
Added:
Modified:
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
index a852a158a2df..4707115c41fc 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorRewriting.cpp
@@ -132,18 +132,19 @@ static RankedTensorType getUnorderedCOOFromType(RankedTensorType src) {
auto rank = src.getRank();
SmallVector<DimLevelType, 4> dims;
- // An unordered and non-unique compressed dim at beginning unless the tensor
- // is a 1D tensor.
- if (rank > 1)
- dims.push_back(DimLevelType::CompressedNuNo);
-
- // TODO: it is actually ordered at the level for ordered input.
- // Followed by unordered non-unique n-2 singleton levels.
- std::fill_n(std::back_inserter(dims), rank - 2, DimLevelType::SingletonNuNo);
- // TODO: only if all the inputs (for concatentate) are unique at the last
- // level should the COO has a unique level at the end. Ends by a unordered
- // unique singleton level.
- dims.push_back(DimLevelType::SingletonNo);
+ // An unordered and non-unique compressed dim at beginning.
+ dims.push_back(DimLevelType::CompressedNuNo);
+
+ if (rank > 1) {
+ // TODO: it is actually ordered at the level for ordered input.
+ // Followed by unordered non-unique n-2 singleton levels.
+ std::fill_n(std::back_inserter(dims), rank - 2,
+ DimLevelType::SingletonNuNo);
+ // TODO: only if all the inputs (for concatentate) are unique at the last
+ // level should the COO has a unique level at the end. Ends by a unordered
+ // unique singleton level unless the tensor rank is 1.
+ dims.push_back(DimLevelType::SingletonNo);
+ }
SparseTensorEncodingAttr encSrc = getSparseTensorEncoding(src);
// TODO: Maybe pick the bitwidth based on input/output tensors (probably the
// largest one among them) in the original operation instead of using the
More information about the Mlir-commits
mailing list