Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
e16d731e
X
X2Paddle
项目概览
PaddlePaddle
/
X2Paddle
大约 1 年 前同步成功
通知
328
Star
698
Fork
167
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
26
列表
看板
标记
里程碑
合并请求
4
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
X
X2Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
26
Issue
26
列表
看板
标记
里程碑
合并请求
4
合并请求
4
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
e16d731e
编写于
12月 03, 2020
作者:
S
SunAhong1993
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix the dygraph2static
上级
ba85e189
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
10 addition
and
6 deletion
+10
-6
x2paddle/core/program.py
x2paddle/core/program.py
+10
-6
未找到文件。
x2paddle/core/program.py
浏览文件 @
e16d731e
...
@@ -76,8 +76,6 @@ class PaddleGraph(object):
...
@@ -76,8 +76,6 @@ class PaddleGraph(object):
self
.
source_type
=
source_type
self
.
source_type
=
source_type
self
.
custom_code
=
None
self
.
custom_code
=
None
self
.
inputs_info
=
None
self
.
inputs_info
=
None
self
.
can_dygraph2static
=
True
def
set_name
(
self
,
name
):
def
set_name
(
self
,
name
):
self
.
name
=
name
.
replace
(
"-"
,
"_"
).
replace
(
"/"
,
"_"
)
self
.
name
=
name
.
replace
(
"-"
,
"_"
).
replace
(
"/"
,
"_"
)
...
@@ -167,8 +165,6 @@ class PaddleGraph(object):
...
@@ -167,8 +165,6 @@ class PaddleGraph(object):
self
.
clear_edges
()
self
.
clear_edges
()
outputs_from_nodes
=
dict
()
outputs_from_nodes
=
dict
()
for
layer_id
,
layer
in
self
.
layers
.
items
():
for
layer_id
,
layer
in
self
.
layers
.
items
():
if
layer
.
kernel
==
"custom_layer:Gather"
:
self
.
can_dygraph2static
=
False
for
input_key
,
input_var
in
layer
.
inputs
.
items
():
for
input_key
,
input_var
in
layer
.
inputs
.
items
():
vs
=
input_var
vs
=
input_var
if
not
isinstance
(
vs
,
list
):
if
not
isinstance
(
vs
,
list
):
...
@@ -286,13 +282,21 @@ class PaddleGraph(object):
...
@@ -286,13 +282,21 @@ class PaddleGraph(object):
self
.
gen_dygraph_code
(
save_dir
)
self
.
gen_dygraph_code
(
save_dir
)
self
.
dump_dygraph_parameter
(
save_dir
)
self
.
dump_dygraph_parameter
(
save_dir
)
# 动转静
# 动转静
if
len
(
self
.
inputs_info
)
>
0
and
self
.
can_dygraph2static
:
if
len
(
self
.
inputs_info
)
>
0
:
input_shapes
=
list
()
input_shapes
=
list
()
input_types
=
list
()
input_types
=
list
()
for
input_name
in
self
.
inputs
:
for
input_name
in
self
.
inputs
:
input_shapes
.
append
(
self
.
inputs_info
[
input_name
][
0
])
input_shapes
.
append
(
self
.
inputs_info
[
input_name
][
0
])
input_types
.
append
(
self
.
inputs_info
[
input_name
][
1
])
input_types
.
append
(
self
.
inputs_info
[
input_name
][
1
])
try
:
self
.
dygraph2static
(
save_dir
,
input_shapes
,
input_types
)
self
.
dygraph2static
(
save_dir
,
input_shapes
,
input_types
)
except
Error
as
e
:
print
(
"The Dygraph2Static is failed! The possible reason are:
\n
"
+
"1. The current model is not supported yet.
\n
"
+
"2. The convertor of pytorch2paddle is wrong. You can run the code of x2paddle.py to confirm the convertor of pytorch2paddle is wrong.
\n
"
+
"The Error is:
\n
"
+
e
)
exit
(
0
)
def
gen_static_code
(
self
,
code_dir
):
def
gen_static_code
(
self
,
code_dir
):
def
write_code
(
f
,
code_list
,
indent
=
0
):
def
write_code
(
f
,
code_list
,
indent
=
0
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录