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

[ControlFlow] replace executor in run method of control flow ops with standalone_executor #45696

Merged
merged 31 commits into from
Oct 31, 2022

Conversation

kangguangli
Copy link
Contributor

@kangguangli kangguangli commented Sep 2, 2022

PR types

Others

PR changes

OPs

Describe

The main content of this pr is to replace executor in run method of conditional block op with standalone_executor. The changes are mainly about two parts: ConditionalBlockOp and InterpreterCore.

  1. Changes about ConditionalBlockOp
    1. replace Executor in RunImpl with InterpreterCore
    2. add class member std::shared_ptr<InterpreterCore> core to cache
    3. use flag FLAGS_control_flow_use_new_executor to decide whether use InterpreterCore
    4. no longer create new scope every times executing ConditionalBlockOp::RunImpl, only when the cached scope is invalid
    5. by default, InterpreterCore will rebuild and reset scope. The scope that was used to initialized it may be invalid, since it may be dropped by outer executor.
  2. Changes about InterpreterCore
    1. add parameter used_for_control_flow_op for the initialization of InterpreterCore
    2. The executor in control flow does not need return value, so add a parameter need_fetch in InterpreterCore::Run
    3. interpretercore_utils.cc::BuildVariableScope should put persistent variables in global scope, which is the root of the scope tree.
    4. control flow block won't contains variables which occur in outer block, so these variables should be skipped in gc.
    5. for interpretercore_util.cc::BuildVariableMap, some inputs or outputs of op in the control flow block is recorded in outer block, so the corresponding variables should be queried recursively.
  3. Other changes
    1. sometimes the layout of variable will be changed after first execution of executor, so there's no need to execute transfer_layout really. We simply call memcpy instead.

@paddle-bot
Copy link

paddle-bot bot commented Sep 2, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@kangguangli kangguangli changed the title replace executor in run method of control flow ops with standalone_executor [NPU] replace executor in run method of control flow ops with standalone_executor Sep 16, 2022
@kangguangli kangguangli requested review from 0x45f and From00 and removed request for 0x45f October 19, 2022 12:12
1. remove flag use in conditional_block_op
2. pass execution_config to BuildOpFuncList instead of individual parameter
zhiqiu
zhiqiu previously approved these changes Oct 28, 2022
Copy link
Contributor

@zhiqiu zhiqiu left a comment

Choose a reason for hiding this comment

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

LGTM

@kangguangli kangguangli changed the title [NPU] replace executor in run method of control flow ops with standalone_executor [ControlFlow] replace executor in run method of control flow ops with standalone_executor Oct 28, 2022
From00
From00 previously approved these changes Oct 28, 2022
Copy link
Contributor

@Aurelius84 Aurelius84 left a comment

Choose a reason for hiding this comment

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

LGTM

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.

7 participants