[Mlir-commits] [mlir] 3360a23 - [mlir][SparseTensor] Fix type conversion rule (#140350)
llvmlistbot at llvm.org
llvmlistbot at llvm.org
Sat May 17 17:21:37 PDT 2025
Author: Matthias Springer
Date: 2025-05-18T09:21:33+09:00
New Revision: 3360a23e60b00fb0260b2aa37495867cff3ec40d
URL: https://github.com/llvm/llvm-project/commit/3360a23e60b00fb0260b2aa37495867cff3ec40d
DIFF: https://github.com/llvm/llvm-project/commit/3360a23e60b00fb0260b2aa37495867cff3ec40d.diff
LOG: [mlir][SparseTensor] Fix type conversion rule (#140350)
A type conversion rule cannot make any assumptions about the number of
pre-existing types in the `results` vector.
This commit fixes a failed assertion in a SparseTensor type conversion
rule. This is only reproducible when type conversion caching is
deactivated. There's no way to do this at the moment. This commit is in
preparation of adding context-aware type conversions, which will
deactivate type caching in such cases.
Added:
Modified:
mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp
index 8bbb2cac5efdf..79602a22dc1fe 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorDescriptor.cpp
@@ -38,12 +38,13 @@ convertSparseTensorType(RankedTensorType rtp, SmallVectorImpl<Type> &fields) {
if (!stt.hasEncoding())
return std::nullopt;
+ unsigned numFields = fields.size();
foreachFieldAndTypeInSparseTensor(
stt,
- [&fields](Type fieldType, FieldIndex fieldIdx,
- SparseTensorFieldKind /*fieldKind*/, Level /*lvl*/,
- LevelType /*lt*/) -> bool {
- assert(fieldIdx == fields.size());
+ [&](Type fieldType, FieldIndex fieldIdx,
+ SparseTensorFieldKind /*fieldKind*/, Level /*lvl*/,
+ LevelType /*lt*/) -> bool {
+ assert(numFields + fieldIdx == fields.size());
fields.push_back(fieldType);
return true;
});
More information about the Mlir-commits
mailing list