-
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
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
fbd3604
Split Executor.Run to Executor.Prepare and Executor.RunPreparedContex…
Xreki 3a82578
Merge branch 'develop' into core_inference_prepare
Xreki 7b40f7c
Merge branch 'develop' into core_inference_prepare
Xreki a9e826e
Add the check of has_feed/fetch_operators back.
Xreki 8a2667c
Merge branch 'develop' into core_inference_prepare
Xreki bf48599
Merge branch 'develop' into core_inference_prepare
Xreki 339be62
Refine the order of arguments.
Xreki 2762959
Merge branch 'develop' into core_inference_prepare
Xreki 449bdde
Correct some typos.
Xreki File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -88,7 +88,7 @@ void CheckError(const paddle::framework::LoDTensor& output1, | |
| EXPECT_EQ(count, 0U) << "There are " << count << " different elements."; | ||
| } | ||
|
|
||
| template <typename Place> | ||
| template <typename Place, bool PrepareContext = false> | ||
| void TestInference(const std::string& dirname, | ||
| const std::vector<paddle::framework::LoDTensor*>& cpu_feeds, | ||
| const std::vector<paddle::framework::LoDTensor*>& cpu_fetchs, | ||
|
|
@@ -167,7 +167,14 @@ void TestInference(const std::string& dirname, | |
| // 6. Run the inference program | ||
| { | ||
| // Ignore the profiling results of the first run | ||
| executor.Run(*inference_program, scope, feed_targets, fetch_targets); | ||
| std::unique_ptr<paddle::framework::ExecutorPrepareContext> ctx; | ||
| if (PrepareContext) { | ||
| ctx = executor.Prepare(*inference_program, 0); | ||
| executor.RunPreparedContext(ctx.get(), scope, feed_targets, | ||
| fetch_targets); | ||
| } else { | ||
| executor.Run(*inference_program, scope, feed_targets, fetch_targets); | ||
| } | ||
|
|
||
| // Enable the profiler | ||
| paddle::platform::EnableProfiler(state); | ||
|
|
@@ -178,7 +185,14 @@ void TestInference(const std::string& dirname, | |
| "run_inference", | ||
| paddle::platform::DeviceContextPool::Instance().Get(place)); | ||
|
|
||
| executor.Run(*inference_program, scope, feed_targets, fetch_targets); | ||
| if (PrepareContext) { | ||
| // Note: if you changed the inference_program, you need to call | ||
|
||
| // executor.Prepare() again to get a new ExecutorPrepareContext. | ||
| executor.RunPreparedContext(ctx.get(), scope, feed_targets, | ||
| fetch_targets); | ||
| } else { | ||
| executor.Run(*inference_program, scope, feed_targets, fetch_targets); | ||
| } | ||
| } | ||
|
|
||
| // Disable the profiler and print the timing information | ||
|
|
||
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.
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.
这似乎是一种英语句法:https://zhidao.baidu.com/question/6942604.html
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.
这似乎是一种英语句法:https://zhidao.baidu.com/question/6942604.html