-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
[PD FE] loading weight from ov::tensor #20044
[PD FE] loading weight from ov::tensor #20044
Conversation
ee9ff4f
to
2db9049
Compare
OPENVINO_SUPPRESS_DEPRECATED_START | ||
std::istream* variant_to_stream_ptr(const ov::Any& variant, | ||
std::ifstream& ext_ifstream, | ||
std::stringstream& ext_sstream) { |
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.
Can we merge std::ifstream& ext_ifstream
and std::stringstream& ext_sstream
into together, because we can see that each branch only uses one of them.
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.
Can we merge
std::ifstream& ext_ifstream
andstd::stringstream& ext_sstream
into together, because we can see that each branch only uses one of them.
@riverlijunjie I simplify the function variant_to_stream_ptr. Please review when you are free.
b862128
to
c7eba6f
Compare
9dbd1be
to
cb67ba3
Compare
cb67ba3
to
f5f9072
Compare
// PDPD API ParseFromIstream always deconstructs the context in model stream. | ||
// So, make a copy for variants[0] to avoid breaking the context in variants[0]. | ||
const auto p_model_stream = variants[0].as<std::istream*>(); | ||
std::istream copy_model_stream(p_model_stream->rdbuf()); |
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.
This is another issue fixing? Do we have other idea to avoid context desconstruction except for doing copy?
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.
This is another issue fixing? Do we have other idea to avoid context desconstruction except for doing copy?
@riverlijunjie No, it is not a new bug. It is a related-bug when loading from memory and no test case to cover.
Actually, it cannot be avoided but don't worry too much. The copy behavior is just about model file instead of weight file so the negative impact is little.
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
@@ -135,22 +135,32 @@ bool normalize_framework_node(const std::shared_ptr<FrameworkNode>& node, | |||
return true; | |||
} | |||
|
|||
std::istream* variant_to_stream_ptr(const ov::Any& variant, std::ifstream& ext_stream) { | |||
OPENVINO_SUPPRESS_DEPRECATED_START | |||
std::istream* variant_to_stream_ptr(const ov::Any& variant, std::fstream& fs, std::stringstream& ss) { |
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.
Can we use fstream to handle case of AlignedBuffer? Any particular reason to use stringstream?
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.
Maybe not. @ceciliapeng2011
- fstream should be open before use but no file can be open.
- The return type is
istream
so we should return a derived type pointer. AFAIK, stringstream as a derived type can be filled with an internal buffer.
* fix paddle load model from memory * fix coding style * ignore the deprecated api * fix a istream bug; add test case * simplify func variant_to_stream_ptr * restore the previous impl for less memory affect * fix memory leak
@ceciliapeng2011 @riverlijunjie |
* fix paddle load model from memory * fix coding style * ignore the deprecated api * fix a istream bug; add test case * simplify func variant_to_stream_ptr * restore the previous impl for less memory affect * fix memory leak
Details:
Tickets: