-
Couldn't load subscription status.
- Fork 5.9k
Add inplace strategy bak #30467
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
Closed
Closed
Add inplace strategy bak #30467
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… add_view_strategy
… add_view_strategy
… add_inplace_strategy
|
Thanks for your contribution! |
… pull30103inplace
cf7e150 to
346b2cc
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR types
New features
PR changes
APIs
Describe
PR #30103 的备份PR
动态图支持Inplace策略:不新建输出VarBase,直接将输入VarBase传递给输出。与静态图已添加Inplace策略的op对齐。为与该策略相关的OP新增python API接口。
支持的OP
与静态图已支持Inplace策略的OP对齐,一共有38个。在这个PR中,为
squeeze2、unsqueeze2、reshape2、scatterelu、relu、softmax、tanh8个OP添加了Inplace策略。其它OP后续会添加Inplace支持。API接口
为需要使用Inplace策略的OP新增python API接口,API名称为现有API名称加上下划线_,用户可选择是否使用这类API组网。
对上述8个OP,对应添加python API接口:
squeeze_、unsqueeze_、reshape_、scatter_elu_、relu_、softmax_、tanh_。生成的op function
在op_function_generator层面添加动态图Inplace机制,以squeeze2 op为例,添加Inplace策略后,生成的op function为
imperative_squeeze2_。主要改变为:
stop_gradient=False的叶子节点,如果是,则会报错。inplace_version增加1。squeeze_()API使用示例Inplace报错
stop_gradient=False的叶子节点实现要点