-
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
Better version of PR #7985 (Modify load() for inference) #8024
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
e556d23
Refine load
sidgoyal78 503f73a
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
sidgoyal78 749e33e
Address review comments: round 1
sidgoyal78 f8570e6
Make API consistent with python-save/load
sidgoyal78 076e0e5
Add another unit test
sidgoyal78 0692742
Remove commented function
sidgoyal78 b17af18
Fix GPU bug
sidgoyal78 e2b88c8
Address review comments
sidgoyal78 55f40e5
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
sidgoyal78 19343d4
Modify wrt PR 8147
sidgoyal78 4177474
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
sidgoyal78 a6f0b0f
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
sidgoyal78 e0f8e74
Fix filenames for combined case
sidgoyal78 8fb97bc
Fix typo
sidgoyal78 e813d13
Address review comments: round 2
sidgoyal78 5430ddd
Resolve merge conflict
sidgoyal78 83b4616
Unify TestInference by keeping default param in template
sidgoyal78 8a002ce
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
sidgoyal78 4d61569
Merge branch 'develop' of https://github.com/PaddlePaddle/Paddle into…
sidgoyal78 805b415
Address review comment
sidgoyal78 33570f7
Fix spacing
sidgoyal78 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 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 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 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 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 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 |
---|---|---|
|
@@ -342,7 +342,11 @@ def save_inference_model(dirname, | |
prepend_feed_ops(inference_program, feeded_var_names) | ||
append_fetch_ops(inference_program, fetch_var_names) | ||
|
||
model_file_name = dirname + "/__model__" | ||
if save_file_name == None: | ||
model_file_name = dirname + "/__model__" | ||
else: | ||
model_file_name = dirname + "/__model_combined__" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The naming style is not friendly for users. We need to refine this interface. |
||
|
||
with open(model_file_name, "wb") as f: | ||
f.write(inference_program.desc.serialize_to_string()) | ||
|
||
|
@@ -384,7 +388,11 @@ def load_inference_model(dirname, executor, load_file_name=None): | |
if not os.path.isdir(dirname): | ||
raise ValueError("There is no directory named '%s'", dirname) | ||
|
||
model_file_name = dirname + "/__model__" | ||
if load_file_name == None: | ||
model_file_name = dirname + "/__model__" | ||
else: | ||
model_file_name = dirname + "/__model_combined__" | ||
|
||
with open(model_file_name, "rb") as f: | ||
program_desc_str = f.read() | ||
|
||
|
This file contains 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 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.
Tensor and LoDTensor have no name. If there is something wrong (for example, user coincidentally gives a wrong param_filename), there is no warning information at all. It will be difficult for users to debug. Can we add another mechanism to check or ensure the correctness? We can refer to other frameworks. Also, this can be done in next 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.
Good point, will think about it and as you mentioned will do later.