Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
3cf5a607
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看板
提交
3cf5a607
编写于
7月 17, 2019
作者:
J
jiangjiajun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
{add codes
上级
0e572fc5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
42 addition
and
6 deletion
+42
-6
x2paddle/core/fluid_code.py
x2paddle/core/fluid_code.py
+29
-2
x2paddle/core/graph.py
x2paddle/core/graph.py
+13
-4
未找到文件。
x2paddle/core/fluid_code.py
浏览文件 @
3cf5a607
...
...
@@ -32,8 +32,35 @@ class Layer(object):
layer_code
=
layer_code
+
"fluid.layers."
+
self
.
op
+
"("
for
key
,
tensor
in
self
.
inputs
.
items
():
layer_code
=
layer_code
+
key
+
"={}, "
.
format
(
tensor
)
if
isinstance
(
self
.
inputs
,
list
):
in_list
=
"["
for
input
in
self
.
inputs
:
assert
isinstance
(
input
,
GraphNode
),
"Type of input should be GraphNode"
if
hasattr
(
input
,
"index"
):
in_list
+=
(
input
.
layer_name
+
"[{}]"
.
format
(
input
.
index
)
+
", "
)
else
:
in_list
+=
(
input
.
layer_name
+
", "
)
inlist
=
in_list
.
strip
(
", "
)
+
"], "
elif
isinstance
(
self
.
inputs
,
dict
):
for
key
,
input
in
self
.
inputs
.
items
():
assert
isinstance
(
input
,
GraphNode
),
"Type of input should be GraphNode"
if
hasattr
(
input
,
"index"
):
layer_code
=
layer_code
+
key
+
"={}, "
.
format
(
input
.
layer_name
+
"[{}]"
.
format
(
input
.
index
))
else
:
layer_code
=
layer_code
+
key
+
"={}, "
.
format
(
input
.
layer_name
)
elif
isinstance
(
self
.
inputs
,
GraphNode
):
if
hasattr
(
self
.
inputs
,
"index"
):
layer_code
+=
(
self
.
inputs
.
layer_name
+
"[{}]"
.
format
(
self
.
inputs
.
index
)
+
", "
)
else
:
layer_code
+=
(
self
.
inputs
.
layer_name
+
", "
)
else
:
raise
Exception
(
"Unknown type of inputs."
)
for
key
,
value
in
self
.
param_attr
.
items
():
layer_code
=
layer_code
+
key
+
"={}, "
.
format
(
value
)
...
...
x2paddle/core/graph.py
浏览文件 @
3cf5a607
...
...
@@ -13,6 +13,7 @@
# limitations under the License.
import
collections
from
copy
import
deepcopy
class
GraphNode
(
object
):
...
...
@@ -72,16 +73,24 @@ class Graph(object):
self
.
topo_sort
.
append
(
node
)
idx
+=
1
def
get_node
(
self
,
name
):
def
get_node
(
self
,
name
,
copy
=
False
):
if
name
not
in
self
.
node_map
:
if
name
.
split
(
':'
)[
0
]
in
self
.
node_map
:
name_prefix
,
idx
=
name
.
split
(
':'
)
self
.
node_map
[
name_prefix
].
index
=
int
(
idx
)
return
self
.
node_map
[
name_prefix
]
if
copy
:
node
=
deepcopy
(
self
.
node_map
[
name_prefix
])
else
:
node
=
self
.
node_map
[
name_prefix
]
node
.
index
=
int
(
idx
)
return
node
else
:
raise
Exception
(
"Graph doesn't have node [%s]."
%
name
)
else
:
return
self
.
node_map
[
name
]
if
copy
:
node
=
deepcopy
(
self
.
node_map
[
name
])
else
:
node
=
self
.
node_map
[
name
]
return
node
def
connect
(
self
,
src
,
dst
):
if
dst
not
in
self
.
node_map
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录