-
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
paddle.save/paddle.static.save 升级pickle的版本 #31044
paddle.save/paddle.static.save 升级pickle的版本 #31044
Conversation
Thanks for your contribution! |
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/paddle/fluid/io.py
Outdated
@@ -1799,6 +1806,14 @@ def save(program, model_path): | |||
assert base_name != "", \ | |||
"The input model_path MUST be format of dirname/filename [dirname\\filename in Windows system], but received model_path is empty string." | |||
|
|||
if not isinstance(protocol, int): | |||
raise ValueError("The 'protocol' should be `int`,but received {}". |
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.
,but
中间加空格
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.
thx,done.
python/paddle/fluid/io.py
Outdated
format(type(protocol))) | ||
|
||
if protocol < 2 or protocol > 4: | ||
raise ValueError("Expected 1<'protocol'<5 ,but received protocol={}". |
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.
,but
-> , but
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.
thx,done.
python/paddle/framework/io.py
Outdated
@@ -254,26 +255,36 @@ def save(obj, path): | |||
"[dirname\\filename in Windows system], but received " | |||
"filename is empty string.") | |||
|
|||
if not isinstance(protocol, int): | |||
raise ValueError("The 'protocol' MUST be `int`,but received {}".format( |
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.
same above
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.
thx,done.
python/paddle/framework/io.py
Outdated
type(protocol))) | ||
|
||
if protocol < 2 or protocol > 4: | ||
raise ValueError("Expected 1<'protocol'<5 ,but received protocol={}". |
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.
same above
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.
thx,done.
810763d
to
5bdf1db
Compare
python/paddle/fluid/io.py
Outdated
@@ -1771,6 +1778,8 @@ def save(program, model_path): | |||
Args: | |||
program(Program) : The program to saved. | |||
model_path(str): the file prefix to save the program. The format is "dirname/file_prefix". If file_prefix is empty str. A exception will be raised | |||
pickle_protocol(int, optional): The protocol version of pickle module must be greater than 1 and less than 5. | |||
Default: None |
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.
Default是2?
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.
thx,done
python/paddle/framework/io.py
Outdated
@@ -218,6 +219,8 @@ def save(obj, path): | |||
obj(Object) : The object to be saved. | |||
path(str) : The path of the object to be saved. | |||
If saved in the current directory, the input path string will be used as the file name. | |||
pickle_protocol(int, optional): The protocol version of pickle module must be greater than 1 and less than 5. | |||
Default: None |
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.
done,thx。
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
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
i * MAX_NUMBER_OF_ELEMENT:MAX_NUMBER_OF_ELEMENT * (i + 1 | ||
)] | ||
|
||
if 1 < protocol < 4: |
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.
对特定版本的特殊处理逻辑最好注释解释一下,方便其他人理解以及后续维护,可以在后续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.
thx.
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
495c573
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
Co-authored-by: lanxianghit <47554610+lanxianghit@users.noreply.github.com>
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
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
* add default argument for paddle.save/static.save * edit documentation of * Add comments for special processing for protocol=2 and protocol=3. * Update python/paddle/fluid/io.py Co-authored-by: lanxianghit <47554610+lanxianghit@users.noreply.github.com> Co-authored-by: lanxianghit <47554610+lanxianghit@users.noreply.github.com>
PR types
Others
PR changes
APIs
Describe
一、主要修改
二、Example:
三、TODO:
四、注意:
五、文档修改:
PaddlePaddle/docs#3258
PaddlePaddle/docs#3272
六、文档预览:
paddle.save
paddle.static.save