[clang-tools-extra] [clang] [mlir] [llvm] [MLIR][Linalg] Support dynamic sizes in `lower_unpack` (PR #75494)
lorenzo chelini via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 18 02:12:29 PST 2023
================
@@ -434,8 +429,21 @@ FailureOr<LowerUnPackOpResult> linalg::lowerUnPack(RewriterBase &rewriter,
RankedTensorType::Builder(packedTensorType).setShape(stripMinedShape);
RankedTensorType collapsedType = tensor::CollapseShapeOp::inferCollapsedType(
stripMinedTensorType, packingMetadata.reassociations);
+
+ // Get dynamic dims from input tensor in order of stripMinedTensor
+ // `tensor.empty` op
+ SmallVector<OpFoldResult, 4> dims =
+ tensor::getMixedSizes(rewriter, loc, unPackOp.getSource());
+ applyPermutationToVector(dims, lastDimsToInsertPositionsPerm);
+ SmallVector<Value, 4> dynDims;
----------------
chelini wrote:
We can avoid the loop using another builder method for emptyOp:
```
SmallVector<OpFoldResult> dims =
tensor::getMixedSizes(rewriter, loc, unPackOp.getSource());
applyPermutationToVector(dims, lastDimsToInsertPositionsPerm);
auto emptyOp = rewriter.create<tensor::EmptyOp>(
loc, dims, stripMinedTensorType.getElementType());
```
https://github.com/llvm/llvm-project/pull/75494
More information about the cfe-commits
mailing list