Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
e8bd0eaa
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看板
提交
e8bd0eaa
编写于
12月 20, 2019
作者:
J
jiangjiajun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
bug modify for image matting
上级
da805be1
变更
3
显示空白变更内容
内联
并排
Showing
3 changed file
with
44 addition
and
12 deletion
+44
-12
x2paddle/core/op_mapper.py
x2paddle/core/op_mapper.py
+2
-1
x2paddle/decoder/tf_decoder.py
x2paddle/decoder/tf_decoder.py
+24
-9
x2paddle/op_mapper/tf_op_mapper.py
x2paddle/op_mapper/tf_op_mapper.py
+18
-2
未找到文件。
x2paddle/core/op_mapper.py
浏览文件 @
e8bd0eaa
...
@@ -25,7 +25,8 @@ def export_paddle_param(param, param_name, dir):
...
@@ -25,7 +25,8 @@ def export_paddle_param(param, param_name, dir):
"int64"
:
[
framework_pb2
.
VarType
.
INT64
,
'q'
],
"int64"
:
[
framework_pb2
.
VarType
.
INT64
,
'q'
],
"float16"
:
[
framework_pb2
.
VarType
.
FP16
,
'e'
],
"float16"
:
[
framework_pb2
.
VarType
.
FP16
,
'e'
],
"float32"
:
[
framework_pb2
.
VarType
.
FP32
,
'f'
],
"float32"
:
[
framework_pb2
.
VarType
.
FP32
,
'f'
],
"float64"
:
[
framework_pb2
.
VarType
.
FP64
,
'd'
]
"float64"
:
[
framework_pb2
.
VarType
.
FP64
,
'd'
],
"bool"
:
[
framework_pb2
.
VarType
.
BOOL
,
None
]
}
}
shape
=
param
.
shape
shape
=
param
.
shape
if
len
(
shape
)
==
0
:
if
len
(
shape
)
==
0
:
...
...
x2paddle/decoder/tf_decoder.py
浏览文件 @
e8bd0eaa
...
@@ -25,20 +25,26 @@ import sys
...
@@ -25,20 +25,26 @@ import sys
class
TFGraphNode
(
GraphNode
):
class
TFGraphNode
(
GraphNode
):
def
__init__
(
self
,
layer
,
layer_name
=
None
,
data_format
=
"NHWC"
):
def
__init__
(
self
,
layer
,
layer_name
=
None
,
data_format
=
"NHWC"
):
if
layer_name
is
None
:
if
layer_name
is
None
:
super
(
TFGraphNode
,
super
(
TFGraphNode
,
self
).
__init__
(
self
).
__init__
(
layer
,
layer
,
layer
.
name
.
replace
(
'/'
,
'_'
).
replace
(
'-'
,
'_
'
))
layer
.
name
.
replace
(
'/'
,
'_'
).
replace
(
'-'
,
'_'
).
replace
(
'^'
,
'
'
))
else
:
else
:
super
(
TFGraphNode
,
super
(
TFGraphNode
,
self
).
__init__
(
self
).
__init__
(
layer
,
layer
,
layer_name
.
replace
(
'/'
,
'_'
).
replace
(
'-'
,
'_
'
))
layer_name
.
replace
(
'/'
,
'_'
).
replace
(
'-'
,
'_'
).
replace
(
'^'
,
'
'
))
self
.
layer_type
=
layer
.
op
self
.
layer_type
=
layer
.
op
self
.
tf_data_format
=
data_format
self
.
tf_data_format
=
data_format
self
.
pd_data_format
=
"NCHW"
self
.
pd_data_format
=
"NCHW"
self
.
fluid_code
=
FluidCode
()
self
.
fluid_code
=
FluidCode
()
self
.
dtype_map
=
{
1
:
"float32"
,
3
:
"int32"
,
4
:
"uint8"
,
9
:
"int64"
}
self
.
dtype_map
=
{
1
:
"float32"
,
3
:
"int32"
,
4
:
"uint8"
,
9
:
"int64"
,
10
:
"bool"
}
@
property
@
property
def
out_shapes
(
self
):
def
out_shapes
(
self
):
...
@@ -113,7 +119,9 @@ class TFGraph(Graph):
...
@@ -113,7 +119,9 @@ class TFGraph(Graph):
for
layer_name
,
node
in
self
.
node_map
.
items
():
for
layer_name
,
node
in
self
.
node_map
.
items
():
for
in_node
in
node
.
layer
.
input
:
for
in_node
in
node
.
layer
.
input
:
in_node
=
in_node
.
replace
(
'/'
,
'_'
).
replace
(
'-'
,
'_'
)
in_node
=
in_node
.
replace
(
'/'
,
'_'
).
replace
(
'-'
,
'_'
).
replace
(
'^'
,
''
)
if
in_node
not
in
self
.
node_map
:
if
in_node
not
in
self
.
node_map
:
if
in_node
.
strip
().
split
(
':'
)[
0
]
in
self
.
node_map
:
if
in_node
.
strip
().
split
(
':'
)[
0
]
in
self
.
node_map
:
self
.
connect
(
in_node
.
strip
().
split
(
':'
)[
0
],
layer_name
)
self
.
connect
(
in_node
.
strip
().
split
(
':'
)[
0
],
layer_name
)
...
@@ -140,6 +148,9 @@ class TFGraph(Graph):
...
@@ -140,6 +148,9 @@ class TFGraph(Graph):
node
=
super
(
TFGraph
,
self
).
get_node
(
new_node_name
,
copy
)
node
=
super
(
TFGraph
,
self
).
get_node
(
new_node_name
,
copy
)
if
node
is
None
:
if
node
is
None
:
return
None
return
None
if
node
.
layer_type
==
"Switch"
:
if
hasattr
(
node
,
'index'
):
del
node
.
index
if
len
(
items
)
==
1
and
node
.
layer_type
in
self
.
multi_out_ops
:
if
len
(
items
)
==
1
and
node
.
layer_type
in
self
.
multi_out_ops
:
node
.
index
=
0
node
.
index
=
0
return
node
return
node
...
@@ -184,9 +195,13 @@ class TFGraph(Graph):
...
@@ -184,9 +195,13 @@ class TFGraph(Graph):
del
self
.
topo_sort
[
idx
]
del
self
.
topo_sort
[
idx
]
def
_remove_identity_node
(
self
):
def
_remove_identity_node
(
self
):
identity_ops
=
[
'Identity'
,
'StopGradient'
,
'Switch'
,
'Merge'
,
'PlaceholderWithDefault'
]
identity_node
=
list
()
identity_node
=
list
()
for
node_name
,
node
in
self
.
node_map
.
items
():
for
node_name
,
node
in
self
.
node_map
.
items
():
if
node
.
layer_type
==
"Identity"
or
node
.
layer_type
==
"StopGradient"
:
if
node
.
layer_type
in
identity_ops
:
identity_node
.
append
(
node_name
)
identity_node
.
append
(
node_name
)
for
node_name
in
identity_node
:
for
node_name
in
identity_node
:
...
...
x2paddle/op_mapper/tf_op_mapper.py
浏览文件 @
e8bd0eaa
...
@@ -125,9 +125,9 @@ class TFOpMapper(OpMapper):
...
@@ -125,9 +125,9 @@ class TFOpMapper(OpMapper):
in_node
=
self
.
graph
.
get_node
(
in_node_name
)
in_node
=
self
.
graph
.
get_node
(
in_node_name
)
out_node
=
self
.
graph
.
get_node
(
out_node_name
)
out_node
=
self
.
graph
.
get_node
(
out_node_name
)
index
=
in_node
.
outputs
.
index
(
out_node_name
)
index
=
in_node
.
outputs
.
index
(
out_node_name
)
del
in_node
.
outputs
[
index
]
#
del in_node.outputs[index]
index
=
out_node
.
inputs
.
index
(
in_node_name
)
index
=
out_node
.
inputs
.
index
(
in_node_name
)
del
out_node
.
inputs
[
index
]
#
del out_node.inputs[index]
self
.
omit_nodes
.
append
(
in_node
.
layer_name
)
self
.
omit_nodes
.
append
(
in_node
.
layer_name
)
def
directly_map
(
self
,
node
):
def
directly_map
(
self
,
node
):
...
@@ -624,6 +624,9 @@ class TFOpMapper(OpMapper):
...
@@ -624,6 +624,9 @@ class TFOpMapper(OpMapper):
output
=
node
,
output
=
node
,
param_attr
=
perm
)
param_attr
=
perm
)
return
return
if
len
(
attr
[
"shape"
])
==
5
:
attr
[
"shape"
]
=
[
attr
[
"shape"
][
i
]
for
i
in
[
0
,
1
,
4
,
2
,
3
]]
node
.
fluid_code
.
add_layer
(
"reshape"
,
node
.
fluid_code
.
add_layer
(
"reshape"
,
inputs
=
input
,
inputs
=
input
,
output
=
node
,
output
=
node
,
...
@@ -893,10 +896,23 @@ class TFOpMapper(OpMapper):
...
@@ -893,10 +896,23 @@ class TFOpMapper(OpMapper):
"starts"
:
begin
,
"starts"
:
begin
,
"ends"
:
end
"ends"
:
end
}
}
shrink_axis_mask
=
node
.
get_attr
(
'shrink_axis_mask'
)
squeeze_dims
=
list
()
for
i
in
range
(
len
(
begin
)):
x
=
shrink_axis_mask
>>
i
&
1
if
x
==
1
:
squeeze_dims
.
append
(
i
)
node
.
fluid_code
.
add_layer
(
"slice"
,
node
.
fluid_code
.
add_layer
(
"slice"
,
inputs
=
input
,
inputs
=
input
,
output
=
node
,
output
=
node
,
param_attr
=
attr
)
param_attr
=
attr
)
if
shrink_axis_mask
>
0
and
len
(
input
.
out_shapes
[
0
])
==
5
:
attr
=
{
"axes"
:
squeeze_dims
}
node
.
fluid_code
.
add_layer
(
"squeeze"
,
inputs
=
node
,
output
=
node
,
param_attr
=
attr
)
def
Slice
(
self
,
node
):
def
Slice
(
self
,
node
):
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
],
copy
=
True
)
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
],
copy
=
True
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录