-
Notifications
You must be signed in to change notification settings - Fork 2
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
Implement optree transformation: Join identical conditional branches #176
base: main
Are you sure you want to change the base?
Conversation
auto ifOp = op->as<IfOp>(); | ||
if (auto elseOp = ifOp.elseOp()) { | ||
auto thenOp = ifOp.thenOp(); | ||
if (elseOp->body.size() == thenOp->body.size()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Вроде бы можно просто функцию сверху заколить через ренж
compiler/lib/backend/optree/optimizer/transforms/join_conditions_branches.cpp
Fixed
Show fixed
Hide fixed
compiler/lib/backend/optree/optimizer/transforms/join_conditions_branches.cpp
Fixed
Show fixed
Hide fixed
compiler/lib/backend/optree/optimizer/transforms/join_conditions_branches.cpp
Fixed
Show fixed
Hide fixed
compiler/lib/backend/optree/optimizer/transforms/join_conditions_branches.cpp
Fixed
Show fixed
Hide fixed
compiler/lib/backend/optree/optimizer/transforms/join_conditions_branches.cpp
Fixed
Show fixed
Hide fixed
compiler/lib/backend/optree/optimizer/transforms/join_conditions_branches.cpp
Fixed
Show fixed
Hide fixed
compiler/lib/backend/optree/optimizer/transforms/join_conditions_branches.cpp
Fixed
Show fixed
Hide fixed
compiler/lib/backend/optree/optimizer/transforms/join_conditions_branches.cpp
Fixed
Show fixed
Hide fixed
static inline bool compareOperations(const Operation::Ptr &lhs, const Operation::Ptr &rhs) { | ||
auto attrEqual = [](const Attribute &lhs, const Attribute &rhs) { return lhs.storage == rhs.storage; }; | ||
bool attr = std::ranges::equal(lhs->attributes, rhs->attributes, attrEqual); | ||
auto valueEqual = [](const Value::Ptr &lhs, const Value::Ptr &rhs) { return lhs->type == rhs->type; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Это неправильное сравнение. Например, два таких body по твоей логике будут одинаковые, хотя value 0 и 1 используются по разному:
Op1 (...) -> (#0: float)
Op2 (...) -> (#1: float)
Op3 (#0, #1) -> (...)
---
Op1 (...) -> (#0: float)
Op2 (...) -> (#1: float)
Op3 (#1, #0) -> (...)
И более простой случай (если 0 и 1 созданы где-то снаружи):
Op1 (#0: float, #1: float) -> (...)
---
Op1 (#1: float, #0: float) -> (...)
А еще у операций есть specId и name, которые тоже должны совпадать. Надо бы вынести все это в отдельную функцию в helpers, по идее #179
No description provided.