Skip to content
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

Remove feature introduced in C++20 to avoid hard dependence to C++20 #877

Merged
merged 3 commits into from
Jan 23, 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
17 changes: 11 additions & 6 deletions mlir/lib/Util/Dependency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,12 +963,17 @@ getAllReadAccessedMemrefOperandsFromOp(Operation *op) {
std::get<2>(entry.second) = strides;
return entry;
};
auto pushMemrefEntryToVector = []<typename T>(T entry,
SmallVector<T> &vector) {
if (!isa<MemRefType>(entry.first.getType()))
return;
vector.push_back(entry);
};
Copy link
Member

Choose a reason for hiding this comment

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

On the other hand you could just use some C++14 Python-esque code like

 auto pushMemrefEntryToVector = [](auto entry, auto &vector) {
    if (!isa<MemRefType>(entry.first.getType()))
      return;
    vector.push_back(entry);
  };

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That works! Thanks for the comment, @keryell!

auto pushMemrefEntryToVector =
[](std::pair<Value, std::tuple<SmallVector<Value>, SmallVector<Value>,
SmallVector<Value>>>
entry,
SmallVector<
std::pair<Value, std::tuple<SmallVector<Value>, SmallVector<Value>,
SmallVector<Value>>>> &vector) {
if (!isa<MemRefType>(entry.first.getType()))
return;
vector.push_back(entry);
};
// Below is an incomplete list of common mlir ops that provide interfaces
// allowing for separating read and write accesses in its operands.
if (auto linalgop = dyn_cast<linalg::LinalgOp>(op)) {
Expand Down
Loading