Skip to content

Commit 296cc29

Browse files
committed
[BACKEND] Fixes removeZeroBasesAlongDim outDims and surjectivity check
1 parent 1d3a335 commit 296cc29

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

lib/Tools/LinearLayout.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,16 @@ LinearLayout LinearLayout::removeZeroBasesAlongDim(StringAttr stripDim) const {
10881088
}
10891089
}
10901090
}
1091-
return LinearLayout(std::move(result), llvm::to_vector(getOutDimNames()));
1091+
SmallVector<std::pair<StringAttr, int32_t>> newOutDimSizes;
1092+
for (auto outDim : getOutDimNames()) {
1093+
newOutDimSizes.push_back({outDim, getOutDimSize(outDim)});
1094+
}
1095+
auto newLayout = LinearLayout(std::move(result), ArrayRef(newOutDimSizes),
1096+
NoCheckInvariants{});
1097+
assert(
1098+
newLayout.isSurjective() == this->isSurjective() &&
1099+
"Removing zero bases along a dimension should not change surjectivity");
1100+
return newLayout;
10921101
}
10931102

10941103
size_t hash_value(const LinearLayout &layout) {

0 commit comments

Comments
 (0)