Skip to content

[MLIR] Avoid vector.extract_strided_slice when not needed #115941

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 1 commit into from
Nov 12, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,13 @@ static Value staticallyExtractSubvector(OpBuilder &rewriter, Location loc,
assert((vectorType.getRank() == 1 && extractType.getRank() == 1) &&
"expected 1-D source and destination types");
(void)vectorType;
assert(frontOffset + subvecSize <= vectorType.getNumElements() &&
"subvector out of bounds");

// do not need extraction if the subvector size is the same as the source
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Use proper sentences in code comments: https://llvm.org/docs/CodingStandards.html#commenting

if (vectorType.getNumElements() == subvecSize)
return source;

auto offsets = rewriter.getI64ArrayAttr({frontOffset});
auto sizes = rewriter.getI64ArrayAttr({subvecSize});
auto strides = rewriter.getI64ArrayAttr({1});
Expand Down
Loading