-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Split Executor.Run to Executor.Prepare and Executor.RunPreparedContext for inference #9630
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
Conversation
luotao1
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.
可以在第一个comment里面补充一些这个PR的背景么,即为什么要拆分成两个?
paddle/fluid/framework/executor.cc
Outdated
| "'%s' variable should be 'FEED_MINIBATCH' type", | ||
| feed_holder_name); | ||
| if (!feed_holder_name.empty()) { | ||
| // When feed operator are present, so should be feed_holder |
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.
- When feed operators are present
- so should be feed_holder缺少主语?
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.
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.
|
|
||
| executor.Run(*inference_program, scope, feed_targets, fetch_targets); | ||
| if (PrepareContext) { | ||
| // Note: if you changed the inference_program, you need to call |
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.
changed->change
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.
Done.
31516c8 to
449bdde
Compare
luotao1
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
In #9000, the basic
Executor.Runwas split into two low-level functions,Executor.PrepareandExecutor.RunPreparedContext. InExecutor.Prepare, operators are created in advance and saved in aExecutorPrepareContext. We can always callExecutor.RunPreparedContextto use theExecutorPrepareContextinstead to avoid frequently creating and destroying of operators if there is no change to the program.For inference, a high level Executor.Run is defined for direct use in C++ inference codes. We should also provide a corresponding high level
Executor.RunPreparedContextif users want to avoid the cost of frequently creating and destroying of operators.