-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Unset ReserveSpace of batch_norm for inference program. #32493
Conversation
Thanks for your contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -413,6 +413,23 @@ def _append_backward_desc(self, infer_program_desc): | |||
# Therefore, in order to reuse the method of backward.py, build the program here. | |||
program = _build_program_by_desc(program_desc_copy) | |||
|
|||
# 3. Add the outputs which is only used for training and not saved in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
小问题,后面是不是还有个3的注释,要不要也顺便更新下
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
看漏了,隔了几行代码才有3,我在后续别的PR里面更新吧。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
PR types
Bug fixes
PR changes
APIs
Describe
batch_norm的ReserveSpace输出只在训练时需要使用,用以保存一些前向计算的临时结果给反向使用。当前save_inference_model因保存了ReserveSpace,导致Lite模型batch_norm相关的pass匹配失败。因此在save_inference_model接口保存预测模型时,将ReserveSpace输出移除。
因有将预测模型加载进来,使用动态图重新训练的需求。所以在将预测program扩展支持训练时,需要将ReserveSpace输出加回来。
测试代码
inference_program模型结构打印如下:
模型可视化如下: