Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion mlir/lib/Dialect/Tosa/Utils/ConversionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ namespace {
// If lower=[a], higher=[a, a], [a] reshaped into [1, a].
// If lower=[a], target=[a, b, a], [a] reshaped into [1, 1, a].
// If lower=[], target=[a, b, c], [] reshaped into [1, 1, 1].
// If lower=[c], higher=[?, ?, c], [c] reshaped into [1, 1, c].
// If lower=[?], higher=[?, ?, ?], [?] reshaped into [1, 1, ?].
LogicalResult
computeReshapeOutput(ArrayRef<int64_t> higherRankShape,
ArrayRef<int64_t> lowerRankShape,
Expand All @@ -87,7 +89,12 @@ computeReshapeOutput(ArrayRef<int64_t> higherRankShape,
higherRankDim = higherRankShape[i + rankDiff];
lowerRankDim = lowerRankShape[i];

if (lowerRankDim != 1 && higherRankDim != 1 &&
auto isStaticDimAndNotEqualToOne = [](int64_t dim) {
return dim != 1 && dim != ShapedType::kDynamic;
};

if (isStaticDimAndNotEqualToOne(lowerRankDim) &&
isStaticDimAndNotEqualToOne(higherRankDim) &&
lowerRankDim != higherRankDim)
return failure();

Expand Down