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

auto graph placement #65

Merged
merged 18 commits into from
Jan 8, 2018
Merged

Conversation

jacquesqiao
Copy link
Member

No description provided.


# init all nodes
for idx in range(len(nodes)):
node_links[idx] = {'input': set(), 'output': set()}
Copy link
Collaborator

Choose a reason for hiding this comment

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

为啥不直接初始化成 list 而是用了 set,然后再变成 list? 是为了避免重复吗? 会有重复吗?

Copy link
Member Author

Choose a reason for hiding this comment

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

change to list()

for in_idx in node_links[idx]['input']:
in_level = node_links[in_idx]['level']
assert in_level is not None
if cur_level is None or in_level >= cur_level:
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里建议用 BFS, 否则如果node的顺序不对,会有bug,比如:

node_0(level 2) -> node_1
node_2(level 3) -> node_0

这样 node_1 会被更新成 3, 但实际应该是4, 因为在node_1 更新后, node_0被再次更新

当然,如果node顺序一定是从小到大的,这么写也没问题。但是BFS更保险。

Copy link
Member Author

Choose a reason for hiding this comment

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

目前node一定是有序的,所以暂时没问题,这个地方目前只做了个基本实现,还需要优化

if in_name in nodes[node_idx]['input']:
node_level = node_links[node_idx]['level']
in_level = node_level - 1
if in_idx not in input_to_level:
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里究竟是要得到什么呢? 是给一个 input,找到它对应的最低level? 如果 input 都是 node,是否可以利用以前的结论直接得到?而不用这么再做一遍?

Copy link
Member Author

Choose a reason for hiding this comment

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

确实是想找到input的最低level,目前input不是node,input比较特殊,没有input,是别的node的input

@jacquesqiao jacquesqiao merged commit 954e679 into PaddlePaddle:develop Jan 8, 2018
jacquesqiao added a commit to jacquesqiao/VisualDL that referenced this pull request Jan 12, 2018
jacquesqiao added a commit to jacquesqiao/VisualDL that referenced this pull request Jan 13, 2018
@jacquesqiao jacquesqiao deleted the auto-placement branch January 13, 2018 06:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants