Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[mlir][vector] add unroll pattern for broadcast #142011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jun 5, 2025
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
fix a bug
  • Loading branch information
chencha3 committed May 29, 2025
commit 496f3061cc0cb1e7b8e432064c1b0e2028d8045c
17 changes: 13 additions & 4 deletions 17 mlir/lib/Dialect/Vector/Transforms/VectorUnroll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -658,14 +658,23 @@ struct UnrollBroadcastPattern : public OpRewritePattern<vector::BroadcastOp> {
for (SmallVector<int64_t> offsets :
StaticTileOffsetRange(originalShape, *targetShape)) {
adam-smnk marked this conversation as resolved.
Show resolved Hide resolved
Value newSrc;
// Scalar to vector broadcast.
if (!srcType) {
// Scalar to vector broadcast.
newSrc = broadcastOp.getSource();
} else {
// Vector to vector broadcast.
int64_t rank = srcType.getRank();
auto srcOffsets = llvm::ArrayRef<int64_t>(offsets).take_back(rank);
auto srcShape = llvm::ArrayRef<int64_t>(*targetShape).take_back(rank);
auto srcStrides = llvm::ArrayRef<int64_t>(strides).take_back(rank);
SmallVector<int64_t> srcOffsets(offsets.end() - rank, offsets.end());
SmallVector<int64_t> srcShape(targetShape->end() - rank,
targetShape->end());
SmallVector<int64_t> srcStrides(strides.end() - rank, strides.end());
// addjust the offset and shape for src if the corresponding dim is 1.
adam-smnk marked this conversation as resolved.
Show resolved Hide resolved
for (int64_t i = 0; i < rank; ++i) {
if (srcType.getDimSize(i) == 1) {
srcOffsets[i] = 0;
srcShape[i] = 1;
}
}
newSrc = rewriter.createOrFold<vector::ExtractStridedSliceOp>(
loc, broadcastOp.getSource(), srcOffsets, srcShape, srcStrides);
}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.