From 5ab1a8aef454b82c409587aa849f4a1d2f1a86f9 Mon Sep 17 00:00:00 2001 From: Peiming Liu Date: Fri, 11 Nov 2022 18:51:25 +0000 Subject: [PATCH] [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 --- mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp b/mlir/lib/Dialect/SparseTensor/Transforms/SparseTensorCodegen.cpp index 499dc4c..d7dd824 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); + } } } -- 2.7.4