[Mlir-commits] [mlir] 5ab1a8a - [mlir][sparse] fix crash when calling getTuple on non-sparse tensors.
Peiming Liu
llvmlistbot at llvm.org
Fri Nov 11 13:15:50 PST 2022
Author: Peiming Liu
Date: 2022-11-11T21:15:44Z
New Revision: 5ab1a8aef454b82c409587aa849f4a1d2f1a86f9
URL: https://github.com/llvm/llvm-project/commit/5ab1a8aef454b82c409587aa849f4a1d2f1a86f9
DIFF: https://github.com/llvm/llvm-project/commit/5ab1a8aef454b82c409587aa849f4a1d2f1a86f9.diff
LOG: [mlir][sparse] fix crash when calling getTuple on non-sparse tensors.
This enables full sparse convolution codegen in D137298
Reviewed By: bixia
Differential Revision: https://reviews.llvm.org/D137853
Added:
Modified:
mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
Removed:
################################################################################
diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
index 499dc4c1ff33..d7dd8240a28c 100644
--- a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
+++ b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp
@@ -59,15 +59,16 @@ static void flattenOperands(ValueRange operands,
// ==>
// memref ..., c, memref ...
for (auto operand : operands) {
- if (auto tuple = getTuple(operand);
- tuple && getSparseTensorEncoding(tuple->getResultTypes()[0]))
+ if (getSparseTensorEncoding(operand.getType())) {
+ auto tuple = getTuple(operand);
// An unrealized_conversion_cast will be inserted by type converter to
// inter-mix the gap between 1:N conversion between sparse tensors and
// fields. In this case, take the operands in the cast and replace the
// sparse tensor output with the flattened type array.
flattened.append(tuple.getOperands().begin(), tuple.getOperands().end());
- else
+ } else {
flattened.push_back(operand);
+ }
}
}
More information about the Mlir-commits
mailing list