Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
6927786f
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看板
提交
6927786f
编写于
3月 18, 2020
作者:
J
jiangjiajun@baidu.com
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add efficient support:
上级
d1b9f2fa
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
5 deletion
+24
-5
x2paddle/convert.py
x2paddle/convert.py
+4
-1
x2paddle/decoder/tf_decoder.py
x2paddle/decoder/tf_decoder.py
+13
-3
x2paddle/op_mapper/tf_op_mapper.py
x2paddle/op_mapper/tf_op_mapper.py
+7
-1
未找到文件。
x2paddle/convert.py
浏览文件 @
6927786f
...
@@ -211,7 +211,10 @@ def main():
...
@@ -211,7 +211,10 @@ def main():
try
:
try
:
import
paddle
import
paddle
v0
,
v1
,
v2
=
paddle
.
__version__
.
split
(
'.'
)
v0
,
v1
,
v2
=
paddle
.
__version__
.
split
(
'.'
)
if
int
(
v0
)
!=
1
or
int
(
v1
)
<
6
:
print
(
"paddle.__version__ = {}"
.
format
(
paddle
.
__version__
))
if
v0
==
'0'
and
v1
==
'0'
and
v2
==
'0'
:
print
(
"[WARNING] You are use develop version of paddlepaddle"
)
elif
int
(
v0
)
!=
1
or
int
(
v1
)
<
6
:
print
(
"[ERROR] paddlepaddle>=1.6.0 is required"
)
print
(
"[ERROR] paddlepaddle>=1.6.0 is required"
)
return
return
except
:
except
:
...
...
x2paddle/decoder/tf_decoder.py
浏览文件 @
6927786f
...
@@ -48,7 +48,10 @@ class TFGraphNode(GraphNode):
...
@@ -48,7 +48,10 @@ class TFGraphNode(GraphNode):
@
property
@
property
def
out_shapes
(
self
):
def
out_shapes
(
self
):
values
=
self
.
layer
.
attr
[
"_output_shapes"
].
list
.
shape
if
self
.
layer_type
==
"OneShotIterator"
:
values
=
self
.
layer
.
attr
[
"output_shapes"
].
list
.
shape
else
:
values
=
self
.
layer
.
attr
[
"_output_shapes"
].
list
.
shape
out_shapes
=
list
()
out_shapes
=
list
()
for
value
in
values
:
for
value
in
values
:
shape
=
[
dim
.
size
for
dim
in
value
.
dim
]
shape
=
[
dim
.
size
for
dim
in
value
.
dim
]
...
@@ -62,6 +65,8 @@ class TFGraphNode(GraphNode):
...
@@ -62,6 +65,8 @@ class TFGraphNode(GraphNode):
dtype
=
self
.
layer
.
attr
[
k
].
type
dtype
=
self
.
layer
.
attr
[
k
].
type
if
dtype
>
0
:
if
dtype
>
0
:
break
break
if
dtype
==
0
:
dtype
=
self
.
layer
.
attr
[
'output_types'
].
list
.
type
[
0
]
if
dtype
not
in
self
.
dtype_map
:
if
dtype
not
in
self
.
dtype_map
:
raise
Exception
(
"Dtype[{}] not in dtype_map"
.
format
(
dtype
))
raise
Exception
(
"Dtype[{}] not in dtype_map"
.
format
(
dtype
))
return
self
.
dtype_map
[
dtype
]
return
self
.
dtype_map
[
dtype
]
...
@@ -226,7 +231,7 @@ class TFGraph(Graph):
...
@@ -226,7 +231,7 @@ class TFGraph(Graph):
def
_remove_identity_node
(
self
):
def
_remove_identity_node
(
self
):
identity_ops
=
[
identity_ops
=
[
'Identity'
,
'StopGradient'
,
'Switch'
,
'Merge'
,
'Identity'
,
'StopGradient'
,
'Switch'
,
'Merge'
,
'PlaceholderWithDefault'
'PlaceholderWithDefault'
,
'IteratorGetNext'
]
]
identity_node
=
list
()
identity_node
=
list
()
for
node_name
,
node
in
self
.
node_map
.
items
():
for
node_name
,
node
in
self
.
node_map
.
items
():
...
@@ -317,7 +322,7 @@ class TFDecoder(object):
...
@@ -317,7 +322,7 @@ class TFDecoder(object):
graph_def
=
cp
.
deepcopy
(
graph_def
)
graph_def
=
cp
.
deepcopy
(
graph_def
)
input_map
=
dict
()
input_map
=
dict
()
for
layer
in
graph_def
.
node
:
for
layer
in
graph_def
.
node
:
if
layer
.
op
!=
"Placeholder"
:
if
layer
.
op
!=
"Placeholder"
and
layer
.
op
!=
"OneShotIterator"
:
continue
continue
graph_node
=
TFGraphNode
(
layer
)
graph_node
=
TFGraphNode
(
layer
)
dtype
=
graph_node
.
layer
.
attr
[
'dtype'
].
type
dtype
=
graph_node
.
layer
.
attr
[
'dtype'
].
type
...
@@ -335,6 +340,11 @@ class TFDecoder(object):
...
@@ -335,6 +340,11 @@ class TFDecoder(object):
if
shape
.
count
(
-
1
)
>
1
:
if
shape
.
count
(
-
1
)
>
1
:
need_define_shape
=
2
need_define_shape
=
2
if
need_define_shape
==
1
:
shape
=
graph_node
.
out_shapes
[
0
]
if
len
(
shape
)
>
0
and
shape
.
count
(
-
1
)
<
2
:
need_define_shape
=
0
if
need_define_shape
>
0
:
if
need_define_shape
>
0
:
shape
=
None
shape
=
None
if
graph_node
.
get_attr
(
"shape"
):
if
graph_node
.
get_attr
(
"shape"
):
...
...
x2paddle/op_mapper/tf_op_mapper.py
浏览文件 @
6927786f
...
@@ -85,7 +85,7 @@ class TFOpMapper(OpMapper):
...
@@ -85,7 +85,7 @@ class TFOpMapper(OpMapper):
not_placeholder
=
list
()
not_placeholder
=
list
()
for
name
in
self
.
graph
.
input_nodes
:
for
name
in
self
.
graph
.
input_nodes
:
if
self
.
graph
.
get_node
(
name
).
layer_type
!=
"Placeholder"
:
if
self
.
graph
.
get_node
(
name
).
layer_type
!=
"Placeholder"
and
self
.
graph
.
get_node
(
name
).
layer_type
!=
"OneShotIterator"
:
not_placeholder
.
append
(
name
)
not_placeholder
.
append
(
name
)
for
name
in
not_placeholder
:
for
name
in
not_placeholder
:
idx
=
self
.
graph
.
input_nodes
.
index
(
name
)
idx
=
self
.
graph
.
input_nodes
.
index
(
name
)
...
@@ -287,6 +287,9 @@ class TFOpMapper(OpMapper):
...
@@ -287,6 +287,9 @@ class TFOpMapper(OpMapper):
output
=
node
,
output
=
node
,
param_attr
=
attr
)
param_attr
=
attr
)
def
OneShotIterator
(
self
,
node
):
return
self
.
Placeholder
(
node
)
def
Const
(
self
,
node
):
def
Const
(
self
,
node
):
shape
=
node
.
out_shapes
[
0
]
shape
=
node
.
out_shapes
[
0
]
dtype
=
node
.
dtype
dtype
=
node
.
dtype
...
@@ -492,6 +495,9 @@ class TFOpMapper(OpMapper):
...
@@ -492,6 +495,9 @@ class TFOpMapper(OpMapper):
output
=
node
,
output
=
node
,
param_attr
=
attr
)
param_attr
=
attr
)
def
FusedBatchNormV3
(
self
,
node
):
return
self
.
FusedBatchNorm
(
node
)
def
DepthwiseConv2dNative
(
self
,
node
):
def
DepthwiseConv2dNative
(
self
,
node
):
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
],
copy
=
True
)
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
],
copy
=
True
)
kernel
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
1
],
copy
=
True
)
kernel
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
1
],
copy
=
True
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录