-
Notifications
You must be signed in to change notification settings - Fork 562
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
drt: Better Dynamic Programming (DP) Nodes and Elimination of getNestedIdx #5901
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
…nction Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
Signed-off-by: bernardo <[email protected]>
clang-tidy review says "All clean, LGTM! 👍" |
Is |
No it is a vector of vectors indeed. Actually, the current implementation represents a matrix (with a lot of empty data). This is what I want to talk about on today's meeting actually, but I gave myself a headstart and already started changing things |
Signed-off-by: bernardo <[email protected]>
clang-tidy review says "All clean, LGTM! 👍" |
Signed-off-by: bernardo <[email protected]>
clang-tidy review says "All clean, LGTM! 👍" |
This PR is branched from #5872 and is waiting for it to merge.
std::vector<FlexDPNode>& nodes
is a convoluted data structure, it has a non intuitive way of indexing nodes and holds a lot of empty data. This is the first PR in a sequences that will refactor this structure to bestd::vector<std::vector<FlexDPNode>>& nodes
, which is a more intuitive data structure for it and will make the code more readable.Here are the changes and how they contribute to this objective:
FlexDPNode Decoupling from old nodes structure
The
FlexDPNode
object holds a the privateprev_node_idx_
which is the index of the previous node in the nodes structure. This was changed so now it holds a pointer to the node itself, if one exists.Other changes were made to the object adding auxiliary methods to make the code more readable, here are some examples:
(curr_node->hasPrevNode())
reads better than(curr_node->getPrevNodeIdx() != -1)
(prev_node->isSource() || curr_node->isDrain())
reads better thanif (prev_idx_1 == -1 || curr_idx_1 == (int) insts.size())
The use of
idx_
as astd::pair<int,int>
allows for getting both values without the use ofgetNestedIdx()
which leads to the second changeElimination of getNestedIdx()
As code was refactored, getting the composed idx directly from node was more convenient and direct than using
getNestedIdx()
, so it was completely eliminated to only get idx from nodes.This required both
getEdgeCost()
functions to getFlexDPNode*
as inputs, instead of node indexes.