[mlir][sparse] misc code cleanup

* Flattening/simplifying some nested conditionals
* const-ifying some local variables

Depends On D143800

Reviewed By: aartbik

Differential Revision: https://reviews.llvm.org/D143949
This commit is contained in:
wren romano
2023-02-15 13:28:11 -08:00
parent 74a5d7471f
commit d950bdc73e
2 changed files with 25 additions and 30 deletions

View File

@@ -1414,20 +1414,18 @@ public:
createOrFoldDimCall(rewriter, loc, srcTp, adaptedOp, concatDim);
offset = rewriter.create<arith::AddIOp>(loc, offset, curDim);
}
if (dstTp.hasEncoding()) {
if (!allDense) {
// In sparse output case, the destination holds the COO.
Value coo = dst;
dst = params.genNewCall(Action::kFromCOO, coo);
// Release resources.
genDelCOOCall(rewriter, loc, elemTp, coo);
} else {
dst = dstTensor;
}
rewriter.replaceOp(op, dst);
} else {
if (!dstTp.hasEncoding()) {
rewriter.replaceOpWithNewOp<bufferization::ToTensorOp>(
op, dstTp.getRankedTensorType(), dst);
} else if (allDense) {
rewriter.replaceOp(op, dstTensor);
} else {
// In sparse output case, the destination holds the COO.
Value coo = dst;
dst = params.genNewCall(Action::kFromCOO, coo);
// Release resources.
genDelCOOCall(rewriter, loc, elemTp, coo);
rewriter.replaceOp(op, dst);
}
return success();
}