Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
2ded6183
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看板
未验证
提交
2ded6183
编写于
10月 12, 2019
作者:
J
Jason
提交者:
GitHub
10月 12, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #161 from mamingjie-China/develop
modify the codes in TensorFlow converting
上级
8fee1a69
ad89666a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
63 addition
and
0 deletion
+63
-0
x2paddle/optimizer/tf_optimizer.py
x2paddle/optimizer/tf_optimizer.py
+63
-0
未找到文件。
x2paddle/optimizer/tf_optimizer.py
浏览文件 @
2ded6183
...
@@ -482,6 +482,69 @@ class TFOptimizer(object):
...
@@ -482,6 +482,69 @@ class TFOptimizer(object):
0
].
inputs
0
].
inputs
del
out_node
.
fluid_code
.
layers
[
0
]
del
out_node
.
fluid_code
.
layers
[
0
]
graph_copy
=
cp
.
deepcopy
(
self
.
graph
)
for
node_name
in
self
.
graph
.
topo_sort
:
node
=
graph_copy
.
get_node
(
node_name
)
if
node
is
None
:
continue
if
node
.
layer_type
in
elementwise_ops
:
can_be_removed
=
True
if
len
(
node
.
fluid_code
.
layers
)
<
3
:
continue
numTranspose
=
0
numNotTranspose
=
0
for
i
in
range
(
len
(
node
.
fluid_code
.
layers
)):
if
node
.
fluid_code
.
layers
[
i
].
op
==
'transpose'
:
numTranspose
+=
1
elif
node
.
fluid_code
.
layers
[
i
].
op
!=
'expand'
:
numNotTranspose
+=
1
if
numTranspose
>
numNotTranspose
:
if
node
.
fluid_code
.
layers
[
0
].
op
==
'expand'
:
if
node
.
fluid_code
.
layers
[
1
].
op
!=
'transpose'
or
node
.
fluid_code
.
layers
[
2
].
op
!=
'transpose'
:
continue
else
:
true_node
=
self
.
graph
.
get_node
(
node_name
)
true_node
.
fluid_code
.
layers
[
3
].
inputs
[
'x'
]
=
true_node
.
fluid_code
.
layers
[
1
].
inputs
true_node
.
fluid_code
.
layers
[
3
].
inputs
[
'y'
]
=
true_node
.
fluid_code
.
layers
[
2
].
inputs
l
=
Layer
()
l
.
op
=
'transpose'
l
.
inputs
=
true_node
.
fluid_code
.
layers
[
3
].
output
l
.
param_attr
=
{
'perm'
:
[
0
,
3
,
1
,
2
]}
if
type
(
l
.
inputs
)
==
str
:
l
.
output
=
l
.
inputs
else
:
l
.
output
=
l
.
inputs
.
layer_name
true_node
.
fluid_code
.
layers
.
append
(
l
)
del
true_node
.
fluid_code
.
layers
[
1
]
del
true_node
.
fluid_code
.
layers
[
1
]
else
:
if
node
.
fluid_code
.
layers
[
0
].
op
!=
'transpose'
or
node
.
fluid_code
.
layers
[
1
].
op
!=
'transpose'
:
continue
else
:
true_node
=
self
.
graph
.
get_node
(
node_name
)
true_node
.
fluid_code
.
layers
[
2
].
inputs
[
'x'
]
=
true_node
.
fluid_code
.
layers
[
0
].
inputs
true_node
.
fluid_code
.
layers
[
2
].
inputs
[
'y'
]
=
true_node
.
fluid_code
.
layers
[
1
].
inputs
l
=
Layer
()
l
.
op
=
'transpose'
l
.
inputs
=
true_node
.
fluid_code
.
layers
[
2
].
output
l
.
param_attr
=
{
'perm'
:
[
0
,
3
,
1
,
2
]}
l
.
output
=
l
.
inputs
.
layer_name
true_node
.
fluid_code
.
layers
.
append
(
l
)
del
true_node
.
fluid_code
.
layers
[
0
]
del
true_node
.
fluid_code
.
layers
[
0
]
def
make_nchw_input_output
(
self
):
def
make_nchw_input_output
(
self
):
for
i
,
name
in
enumerate
(
self
.
graph
.
input_nodes
):
for
i
,
name
in
enumerate
(
self
.
graph
.
input_nodes
):
node
=
self
.
graph
.
get_node
(
name
)
node
=
self
.
graph
.
get_node
(
name
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录