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

Refactor scope #3652

Merged
merged 3 commits into from
Oct 6, 2020
Merged

Refactor scope #3652

merged 3 commits into from
Oct 6, 2020

Conversation

lixinqi
Copy link
Contributor

@lixinqi lixinqi commented Oct 6, 2020

将Scope相关的函数从Session移动到新文件scope_util.py,原来scope_util.py被重命名为scope_symbol.py

Comment on lines 15 to 18
true \
&& ONEFLOW_TEST_DEVICE_NUM=1 python3 -m unittest --failfast --verbose \
&& ONEFLOW_TEST_DEVICE_NUM=2 python3 -m unittest --failfast --verbose \
&& ONEFLOW_TEST_DEVICE_NUM=4 python3 -m unittest --failfast --verbose
Copy link
Contributor Author

Choose a reason for hiding this comment

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

带逻辑截断能最快地failfast

Copy link
Collaborator

@jackalcooper jackalcooper Oct 6, 2020

Choose a reason for hiding this comment

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

什么意思,这个脚本已经加了 set -ex,出错就退出了,不需要加&吧

Copy link
Contributor

Choose a reason for hiding this comment

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

@jackalcooper bash -e 对 && || 的处理比较坑,https://stackoverflow.com/questions/41760057/bash-e-flag-and-list-command ,只有最后一个子命令出错才会退出

Copy link
Contributor Author

Choose a reason for hiding this comment

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

晟航已回滚了这地方的代码

@@ -0,0 +1,129 @@
"""
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这就是旧的scope_util.py,原来名字不太好。

return scope


def MakeInitialScope(job_conf, device_tag, machine_device_ids, is_mirrored):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个函数是从compiler.py移动过来的,其他都是从Session类里移动过来的。

return scope


def InitScopeStack():
Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个在环境初始化之后调用

@@ -70,13 +70,11 @@ def __init__(self):
self.interface_op_name2op_attr_ = {}
self.interface_op_name2job_name_ = {}
self.job_name2name_scope_stack_ = {}
self.job_name2current_scope_ = {}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Scope不需要特别强调是属于哪个job的scope,它都不是Session的成员。

@oneflow-ci-bot oneflow-ci-bot merged commit 278b50a into master Oct 6, 2020
@oneflow-ci-bot oneflow-ci-bot deleted the refactor_scope branch October 6, 2020 16:41
liujuncheng pushed a commit that referenced this pull request Jun 3, 2021
* refactor Session.job_name2current_scope_ to Session.scope_stack_

* Seperate scope related functions from Session to scope_util.py

* revert change

Co-authored-by: Shenghang Tsai <jackalcooper@gmail.com>
Former-commit-id: 278b50a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants