Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
853731b8
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看板
未验证
提交
853731b8
编写于
7月 03, 2020
作者:
J
Jason
提交者:
GitHub
7月 03, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #294 from mamingjie-China/develop
remove infer when converting TF model
上级
0933e73f
b434b7db
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
100 addition
and
237 deletion
+100
-237
x2paddle/op_mapper/tf_op_mapper_nhwc.py
x2paddle/op_mapper/tf_op_mapper_nhwc.py
+92
-223
x2paddle/optimizer/tf_optimizer.py
x2paddle/optimizer/tf_optimizer.py
+8
-14
未找到文件。
x2paddle/op_mapper/tf_op_mapper_nhwc.py
浏览文件 @
853731b8
此差异已折叠。
点击以展开。
x2paddle/optimizer/tf_optimizer.py
浏览文件 @
853731b8
...
@@ -236,26 +236,18 @@ class TFOptimizer(object):
...
@@ -236,26 +236,18 @@ class TFOptimizer(object):
def
remove_transpose
(
self
):
def
remove_transpose
(
self
):
graph_copy
=
cp
.
deepcopy
(
self
.
graph
)
graph_copy
=
cp
.
deepcopy
(
self
.
graph
)
nhwc_insensitive_ops
=
[
'Relu'
,
'Relu6'
,
'Abs'
,
'Sigmoid'
,
'Exp'
,
'Rsqrt'
,
'swish_f32'
,
'LeakyRelu'
,
'Cast'
,
'Tanh'
]
elementwise_ops
=
[
elementwise_ops
=
[
'Sub'
,
'Add'
,
'RealDiv'
,
'Maximum'
,
'Mul'
,
'FloorDiv'
,
'Sub'
,
'Add'
,
'RealDiv'
,
'Maximum'
,
'Mul'
,
'FloorDiv'
,
'GreaterEqual'
'GreateerEqual'
]
optimize_ops
=
[
'Conv2D'
,
'MaxPool'
,
'FusedBatchNorm'
,
'DepthwiseConv2dNative'
,
'AvgPool'
,
'Pad'
,
'Conv2DBackpropInput'
,
'ResizeNearestNeighbor'
,
'ResizeBilinear'
,
"Placeholder"
]
]
can_be_optimized_ops
=
[
can_be_optimized_ops
=
[
'Conv2D'
,
'MaxPool'
,
'FusedBatchNorm'
,
'DepthwiseConv2dNative'
,
'Conv2D'
,
'MaxPool'
,
'FusedBatchNorm'
,
'DepthwiseConv2dNative'
,
'AvgPool'
,
'Pad'
,
'Conv2DBackpropInput'
,
'ResizeNearestNeighbor'
,
'AvgPool'
,
'Pad'
,
'Conv2DBackpropInput'
,
'ResizeNearestNeighbor'
,
'
ResizeBilinear'
,
"Placeholder"
,
'Relu'
,
'Relu6'
,
'Abs'
,
'Sigmoid
'
,
'
Placeholder'
,
'Relu'
,
'Relu6'
,
'Abs'
,
'Sigmoid'
,
'Exp'
,
'Rsqrt
'
,
'
Exp'
,
'Rsqrt'
,
'
swish_f32'
,
'LeakyRelu'
,
'Cast'
,
'Tanh'
'swish_f32'
,
'LeakyRelu'
,
'Cast'
,
'Tanh'
]
]
# These ops may have one more Variable input
can_be_optimized_special_ops
=
[
'ResizeBilinear'
]
for
node_name
in
self
.
graph
.
topo_sort
:
for
node_name
in
self
.
graph
.
topo_sort
:
node
=
graph_copy
.
get_node
(
node_name
)
node
=
graph_copy
.
get_node
(
node_name
)
if
node
is
None
:
if
node
is
None
:
...
@@ -278,9 +270,10 @@ class TFOptimizer(object):
...
@@ -278,9 +270,10 @@ class TFOptimizer(object):
0
].
param_attr
[
"perm"
]
!=
[
0
,
3
,
1
,
2
]:
0
].
param_attr
[
"perm"
]
!=
[
0
,
3
,
1
,
2
]:
can_be_removed
=
False
can_be_removed
=
False
break
break
elif
out_node
.
layer_type
in
elementwise_ops
:
elif
out_node
.
layer_type
in
elementwise_ops
or
out_node
.
layer_type
in
can_be_optimized_special_ops
:
can_be_removed
=
False
can_be_removed
=
False
break
break
if
can_be_removed
and
len
(
node
.
fluid_code
.
layers
)
>
1
:
if
can_be_removed
and
len
(
node
.
fluid_code
.
layers
)
>
1
:
true_node
=
self
.
graph
.
get_node
(
node_name
)
true_node
=
self
.
graph
.
get_node
(
node_name
)
if
true_node
.
layer_type
==
"Placeholder"
:
if
true_node
.
layer_type
==
"Placeholder"
:
...
@@ -298,6 +291,7 @@ class TFOptimizer(object):
...
@@ -298,6 +291,7 @@ class TFOptimizer(object):
-
2
].
output
=
true_node
.
fluid_code
.
layers
[
-
1
].
output
-
2
].
output
=
true_node
.
fluid_code
.
layers
[
-
1
].
output
node
.
removed
=
True
node
.
removed
=
True
del
true_node
.
fluid_code
.
layers
[
-
1
]
del
true_node
.
fluid_code
.
layers
[
-
1
]
for
out_name
in
output_names
:
for
out_name
in
output_names
:
out_node
=
self
.
graph
.
get_node
(
out_name
)
out_node
=
self
.
graph
.
get_node
(
out_name
)
out_node
.
fluid_code
.
layers
[
out_node
.
fluid_code
.
layers
[
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录