-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Fix clone function of Program to avoid memory leak. #10358
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
Fix clone function of Program to avoid memory leak. #10358
Conversation
kexinzhao
left a comment
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! Thank you for fixing this!
| def inference_optimize(self): | ||
| res = Program() | ||
| res.desc = core.inference_optimize(self.desc) | ||
| res.desc = core.ProgramDesc(self.desc) |
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.
我感觉为什么core.inference_optimize的实现有memory leak,原因还不是很确定。这里加个comment说明一下吧,说明这里的功能和core.inference_optimize是一样的以及为什么不用core.inference_optimize的原因吧。
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.
暂时还不确定core.inference_optimize导致memory leak的原因,我加了个comment说明这里的功能和core.inference_optimize一样
python/paddle/fluid/framework.py
Outdated
| p.desc = core.inference_optimize(self.desc) | ||
| else: | ||
| p.desc = core.ProgramDesc(self.desc) | ||
| for i in xrange(p.desc.num_blocks()): |
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.
这里可以调Python的inference_optimize吗?
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.
@wanghaoshuang 觉得这里可以直接调用Python里的: def inference_optimize(self),另外,直接在Python里修正attr is_test=True后,有打印看下inference_program检查过吗?is_test是否变过来了?
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.
这里可以调Python的inference_optimize吗?
Fixed. Thx.
直接在Python里修正attr is_test=True后,有打印看下inference_program检查过吗?is_test是否变过来了?
嗯,已经验证了。
qingqing01
left a comment
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.
fix #10254
for_test=Trueat herewill lead to memory leak while inference is active.
Reference assignment would be more suitablehere.than the pointer assignment