Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
e8caffbb
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
e8caffbb
编写于
7月 24, 2020
作者:
C
Chen Weihang
提交者:
GitHub
7月 24, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix jit.save input_spec type change problem (#25683)
* fix jit.save input type change error * add unittes
上级
364cc536
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
9 addition
and
5 deletion
+9
-5
python/paddle/fluid/dygraph/jit.py
python/paddle/fluid/dygraph/jit.py
+6
-5
python/paddle/fluid/tests/unittests/test_jit_save_load.py
python/paddle/fluid/tests/unittests/test_jit_save_load.py
+3
-0
未找到文件。
python/paddle/fluid/dygraph/jit.py
浏览文件 @
e8caffbb
...
@@ -653,8 +653,9 @@ def save(layer, model_path, input_spec=None, configs=None):
...
@@ -653,8 +653,9 @@ def save(layer, model_path, input_spec=None, configs=None):
"""
"""
def
get_inout_spec
(
all_vars
,
target_vars
,
return_name
=
False
):
def
get_inout_spec
(
all_vars
,
target_vars
,
return_name
=
False
):
valid_vars
=
[
var
for
var
in
all_vars
if
isinstance
(
var
,
Variable
)
]
result_list
=
[
]
valid_var_dict
=
{}
valid_var_dict
=
{}
valid_vars
=
[
var
for
var
in
all_vars
if
isinstance
(
var
,
Variable
)]
for
var
in
valid_vars
:
for
var
in
valid_vars
:
valid_var_dict
[
var
.
name
]
=
var
valid_var_dict
[
var
.
name
]
=
var
if
target_vars
:
if
target_vars
:
...
@@ -663,13 +664,13 @@ def save(layer, model_path, input_spec=None, configs=None):
...
@@ -663,13 +664,13 @@ def save(layer, model_path, input_spec=None, configs=None):
if
var
.
name
not
in
valid_var_dict
:
if
var
.
name
not
in
valid_var_dict
:
raise
RuntimeError
(
raise
RuntimeError
(
"The variable to feed/fetch are not exist."
)
"The variable to feed/fetch are not exist."
)
target_vars
[
i
]
=
valid_var_dict
[
var
.
name
]
result_list
.
append
(
valid_var_dict
[
var
.
name
])
else
:
else
:
target_vars
=
valid_vars
result_list
=
valid_vars
if
return_name
:
if
return_name
:
target_vars
=
[
var
.
name
for
var
in
target_vars
]
result_list
=
[
var
.
name
for
var
in
target_vars
]
return
target_vars
return
result_list
# 1. input check
# 1. input check
prog_translator
=
ProgramTranslator
()
prog_translator
=
ProgramTranslator
()
...
...
python/paddle/fluid/tests/unittests/test_jit_save_load.py
浏览文件 @
e8caffbb
...
@@ -114,8 +114,11 @@ class TestJitSaveLoad(unittest.TestCase):
...
@@ -114,8 +114,11 @@ class TestJitSaveLoad(unittest.TestCase):
def
train_and_save_model
(
self
):
def
train_and_save_model
(
self
):
layer
=
LinearNet
(
784
,
1
)
layer
=
LinearNet
(
784
,
1
)
example_inputs
,
layer
,
_
=
train
(
layer
)
example_inputs
,
layer
,
_
=
train
(
layer
)
orig_input_types
=
[
type
(
x
)
for
x
in
example_inputs
]
fluid
.
dygraph
.
jit
.
save
(
fluid
.
dygraph
.
jit
.
save
(
layer
=
layer
,
model_path
=
self
.
model_path
,
input_spec
=
example_inputs
)
layer
=
layer
,
model_path
=
self
.
model_path
,
input_spec
=
example_inputs
)
new_input_types
=
[
type
(
x
)
for
x
in
example_inputs
]
self
.
assertEqual
(
orig_input_types
,
new_input_types
)
return
layer
return
layer
def
test_save
(
self
):
def
test_save
(
self
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录