Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
42dc4e92
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看板
未验证
提交
42dc4e92
编写于
12月 21, 2020
作者:
J
Jason
提交者:
GitHub
12月 21, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #462 from PaddlePaddle/tf
fix the tf bug
上级
35d52293
6511e005
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
61 addition
and
37 deletion
+61
-37
x2paddle/decoder/tf_decoder.py
x2paddle/decoder/tf_decoder.py
+5
-2
x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py
x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py
+19
-7
x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py
x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py
+33
-14
x2paddle/optimizer/elimination/dygraph/transpose_elimination.py
...le/optimizer/elimination/dygraph/transpose_elimination.py
+2
-7
x2paddle/optimizer/elimination/static/transpose_elimination.py
...dle/optimizer/elimination/static/transpose_elimination.py
+2
-7
未找到文件。
x2paddle/decoder/tf_decoder.py
浏览文件 @
42dc4e92
...
@@ -130,7 +130,7 @@ class TFGraph(Graph):
...
@@ -130,7 +130,7 @@ class TFGraph(Graph):
def
__init__
(
self
,
model
,
data_format
=
"NHWC"
):
def
__init__
(
self
,
model
,
data_format
=
"NHWC"
):
super
(
TFGraph
,
self
).
__init__
(
model
)
super
(
TFGraph
,
self
).
__init__
(
model
)
self
.
identity_map
=
dict
()
self
.
identity_map
=
dict
()
self
.
multi_out_ops
=
[
'Split'
,
'SplitV'
,
'IteratorV2'
]
self
.
multi_out_ops
=
[
'Split'
,
'SplitV'
,
'IteratorV2'
,
'Unpack'
]
self
.
tf_data_format
=
data_format
self
.
tf_data_format
=
data_format
self
.
graph_name
=
"TFModel"
self
.
graph_name
=
"TFModel"
...
@@ -173,6 +173,7 @@ class TFGraph(Graph):
...
@@ -173,6 +173,7 @@ class TFGraph(Graph):
self
.
_optimize_dialiation_conv
()
self
.
_optimize_dialiation_conv
()
self
.
_remove_identity_node
()
self
.
_remove_identity_node
()
self
.
_remove_cast_node
()
self
.
_remove_cast_node
()
def
get_node
(
self
,
node_name
,
copy
=
False
):
def
get_node
(
self
,
node_name
,
copy
=
False
):
items
=
node_name
.
strip
().
split
(
':'
)
items
=
node_name
.
strip
().
split
(
':'
)
...
@@ -192,6 +193,8 @@ class TFGraph(Graph):
...
@@ -192,6 +193,8 @@ class TFGraph(Graph):
def
get_input_node
(
self
,
node
,
idx
=
0
,
copy
=
False
):
def
get_input_node
(
self
,
node
,
idx
=
0
,
copy
=
False
):
input_node_name
=
node
.
layer
.
input
[
idx
]
input_node_name
=
node
.
layer
.
input
[
idx
]
if
idx
>
0
:
copy
=
True
return
self
.
get_node
(
input_node_name
,
copy
)
return
self
.
get_node
(
input_node_name
,
copy
)
def
remove_node
(
self
,
node_name
):
def
remove_node
(
self
,
node_name
):
...
@@ -402,7 +405,7 @@ class TFDecoder(object):
...
@@ -402,7 +405,7 @@ class TFDecoder(object):
right_shape_been_input
=
False
right_shape_been_input
=
False
while
not
right_shape_been_input
:
while
not
right_shape_been_input
:
try
:
try
:
shape
=
input
(
shape
=
raw_
input
(
"Shape of Input(e.g. None,224,224,3): "
)
"Shape of Input(e.g. None,224,224,3): "
)
except
:
except
:
shape
=
input
(
"Shape of Input(e.g. None,224,224,3): "
)
shape
=
input
(
"Shape of Input(e.g. None,224,224,3): "
)
...
...
x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py
浏览文件 @
42dc4e92
...
@@ -73,15 +73,17 @@ class TFOpMapper(OpMapper):
...
@@ -73,15 +73,17 @@ class TFOpMapper(OpMapper):
'Sub'
:
'fluid.layers.elementwise_sub'
,
'Sub'
:
'fluid.layers.elementwise_sub'
,
'Maximum'
:
'paddle.maximum'
,
'Maximum'
:
'paddle.maximum'
,
'Minimum'
:
'paddle.minimum'
,
'Minimum'
:
'paddle.minimum'
,
'Mul'
:
'paddle.multiply'
,
'FloorDiv'
:
'paddle.floor_divide'
,
'FloorMod'
:
'paddle.floor_mod'
,
'LogicalAnd'
:
'logical_and'
,
}
bool_ops
=
{
'LessEqual'
:
'paddle.less_equal'
,
'LessEqual'
:
'paddle.less_equal'
,
'GreaterEqual'
:
'paddle.greater_equal'
,
'GreaterEqual'
:
'paddle.greater_equal'
,
'Greater'
:
'paddle.greater_than'
,
'Greater'
:
'paddle.greater_than'
,
'NotEqual'
:
'paddle.not_equal'
,
'NotEqual'
:
'paddle.not_equal'
,
'Equal'
:
'paddle.equal'
,
'Equal'
:
'paddle.equal'
,
'Mul'
:
'paddle.multiply'
,
'FloorDiv'
:
'paddle.floor_divide'
,
'FloorMod'
:
'paddle.floor_mod'
,
'LogicalAnd'
:
'logical_and'
,
}
}
def
__init__
(
self
,
decoder
):
def
__init__
(
self
,
decoder
):
...
@@ -123,6 +125,8 @@ class TFOpMapper(OpMapper):
...
@@ -123,6 +125,8 @@ class TFOpMapper(OpMapper):
self
.
directly_map
(
node
)
self
.
directly_map
(
node
)
elif
op
in
self
.
elementwise_ops
:
elif
op
in
self
.
elementwise_ops
:
self
.
elementwise_map
(
node
)
self
.
elementwise_map
(
node
)
elif
op
in
self
.
bool_ops
:
self
.
bool_map
(
node
)
elif
hasattr
(
self
,
op
):
elif
hasattr
(
self
,
op
):
func
=
getattr
(
self
,
op
)
func
=
getattr
(
self
,
op
)
func
(
node
)
func
(
node
)
...
@@ -138,7 +142,8 @@ class TFOpMapper(OpMapper):
...
@@ -138,7 +142,8 @@ class TFOpMapper(OpMapper):
op
=
node
.
layer_type
op
=
node
.
layer_type
if
not
hasattr
(
self
,
op
)
and
\
if
not
hasattr
(
self
,
op
)
and
\
op
not
in
self
.
directly_map_ops
and
\
op
not
in
self
.
directly_map_ops
and
\
op
not
in
self
.
elementwise_ops
:
op
not
in
self
.
elementwise_ops
and
\
op
not
in
self
.
bool_ops
:
unsupported_ops
.
add
(
op
)
unsupported_ops
.
add
(
op
)
if
len
(
unsupported_ops
)
==
0
:
if
len
(
unsupported_ops
)
==
0
:
return
True
return
True
...
@@ -178,8 +183,10 @@ class TFOpMapper(OpMapper):
...
@@ -178,8 +183,10 @@ class TFOpMapper(OpMapper):
outputs
=
[
node
.
name
],
outputs
=
[
node
.
name
],
**
layer_attrs
)
**
layer_attrs
)
def
elementwise_map
(
self
,
node
):
def
elementwise_map
(
self
,
node
,
op_type
=
None
):
op_type
=
self
.
elementwise_ops
[
node
.
layer_type
]
if
op_type
is
None
:
assert
node
.
layer_type
in
self
.
elementwise_ops
op_type
=
self
.
elementwise_ops
[
node
.
layer_type
]
x
=
self
.
graph
.
get_input_node
(
node
,
0
)
x
=
self
.
graph
.
get_input_node
(
node
,
0
)
y
=
self
.
graph
.
get_input_node
(
node
,
1
)
y
=
self
.
graph
.
get_input_node
(
node
,
1
)
x_shape
=
x
.
out_shapes
[
0
]
x_shape
=
x
.
out_shapes
[
0
]
...
@@ -190,6 +197,11 @@ class TFOpMapper(OpMapper):
...
@@ -190,6 +197,11 @@ class TFOpMapper(OpMapper):
"y"
:
y
.
name
},
"y"
:
y
.
name
},
outputs
=
[
node
.
name
])
outputs
=
[
node
.
name
])
self
.
paddle_graph
.
layers
[
layer_id
].
input_shapes
=
{
"x"
:
x_shape
,
"y"
:
y_shape
}
self
.
paddle_graph
.
layers
[
layer_id
].
input_shapes
=
{
"x"
:
x_shape
,
"y"
:
y_shape
}
def
bool_map
(
self
,
node
):
op_type
=
self
.
bool_ops
[
node
.
layer_type
]
self
.
elementwise_map
(
node
,
op_type
)
node
.
set_dtype
(
"bool"
)
def
Placeholder
(
self
,
node
):
def
Placeholder
(
self
,
node
):
shape
=
node
.
out_shapes
[
0
]
shape
=
node
.
out_shapes
[
0
]
...
...
x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py
浏览文件 @
42dc4e92
...
@@ -75,15 +75,17 @@ class TFOpMapper(OpMapper):
...
@@ -75,15 +75,17 @@ class TFOpMapper(OpMapper):
'Sub'
:
'fluid.layers.elementwise_sub'
,
'Sub'
:
'fluid.layers.elementwise_sub'
,
'Maximum'
:
'paddle.maximum'
,
'Maximum'
:
'paddle.maximum'
,
'Minimum'
:
'paddle.minimum'
,
'Minimum'
:
'paddle.minimum'
,
'Mul'
:
'paddle.multiply'
,
'FloorDiv'
:
'paddle.floor_divide'
,
'FloorMod'
:
'paddle.floor_mod'
,
'LogicalAnd'
:
'logical_and'
,
}
bool_ops
=
{
'LessEqual'
:
'paddle.less_equal'
,
'LessEqual'
:
'paddle.less_equal'
,
'GreaterEqual'
:
'paddle.greater_equal'
,
'GreaterEqual'
:
'paddle.greater_equal'
,
'Greater'
:
'paddle.greater_than'
,
'Greater'
:
'paddle.greater_than'
,
'NotEqual'
:
'paddle.not_equal'
,
'NotEqual'
:
'paddle.not_equal'
,
'Equal'
:
'paddle.equal'
,
'Equal'
:
'paddle.equal'
,
'Mul'
:
'paddle.multiply'
,
'FloorDiv'
:
'paddle.floor_divide'
,
'FloorMod'
:
'paddle.floor_mod'
,
'LogicalAnd'
:
'logical_and'
,
}
}
def
__init__
(
self
,
decoder
):
def
__init__
(
self
,
decoder
):
...
@@ -94,6 +96,7 @@ class TFOpMapper(OpMapper):
...
@@ -94,6 +96,7 @@ class TFOpMapper(OpMapper):
raise
Exception
(
"Model is not supported yet."
)
raise
Exception
(
"Model is not supported yet."
)
self
.
params
=
dict
()
self
.
params
=
dict
()
self
.
paddle_graph
=
PaddleGraph
(
parent_layer
=
None
,
graph_type
=
"static"
,
source_type
=
"tf"
)
self
.
paddle_graph
=
PaddleGraph
(
parent_layer
=
None
,
graph_type
=
"static"
,
source_type
=
"tf"
)
self
.
params_output2id
=
dict
()
not_placeholder
=
list
()
not_placeholder
=
list
()
for
name
in
self
.
graph
.
input_nodes
:
for
name
in
self
.
graph
.
input_nodes
:
...
@@ -124,6 +127,8 @@ class TFOpMapper(OpMapper):
...
@@ -124,6 +127,8 @@ class TFOpMapper(OpMapper):
self
.
directly_map
(
node
)
self
.
directly_map
(
node
)
elif
op
in
self
.
elementwise_ops
:
elif
op
in
self
.
elementwise_ops
:
self
.
elementwise_map
(
node
)
self
.
elementwise_map
(
node
)
elif
op
in
self
.
bool_ops
:
self
.
bool_map
(
node
)
elif
hasattr
(
self
,
op
):
elif
hasattr
(
self
,
op
):
func
=
getattr
(
self
,
op
)
func
=
getattr
(
self
,
op
)
func
(
node
)
func
(
node
)
...
@@ -138,7 +143,8 @@ class TFOpMapper(OpMapper):
...
@@ -138,7 +143,8 @@ class TFOpMapper(OpMapper):
op
=
node
.
layer_type
op
=
node
.
layer_type
if
not
hasattr
(
self
,
op
)
and
\
if
not
hasattr
(
self
,
op
)
and
\
op
not
in
self
.
directly_map_ops
and
\
op
not
in
self
.
directly_map_ops
and
\
op
not
in
self
.
elementwise_ops
:
op
not
in
self
.
elementwise_ops
and
\
op
not
in
self
.
bool_ops
:
unsupported_ops
.
add
(
op
)
unsupported_ops
.
add
(
op
)
if
len
(
unsupported_ops
)
==
0
:
if
len
(
unsupported_ops
)
==
0
:
return
True
return
True
...
@@ -167,9 +173,10 @@ class TFOpMapper(OpMapper):
...
@@ -167,9 +173,10 @@ class TFOpMapper(OpMapper):
outputs
=
[
node
.
name
],
outputs
=
[
node
.
name
],
**
attr
)
**
attr
)
def
elementwise_map
(
self
,
node
):
def
elementwise_map
(
self
,
node
,
op_type
=
None
):
assert
node
.
layer_type
in
self
.
elementwise_ops
if
op_type
is
None
:
op_type
=
self
.
elementwise_ops
[
node
.
layer_type
]
assert
node
.
layer_type
in
self
.
elementwise_ops
op_type
=
self
.
elementwise_ops
[
node
.
layer_type
]
x
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
])
x
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
])
y
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
1
])
y
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
1
])
x_shape
=
x
.
out_shapes
[
0
]
x_shape
=
x
.
out_shapes
[
0
]
...
@@ -180,6 +187,11 @@ class TFOpMapper(OpMapper):
...
@@ -180,6 +187,11 @@ class TFOpMapper(OpMapper):
"y"
:
y
.
name
},
"y"
:
y
.
name
},
outputs
=
[
node
.
name
])
outputs
=
[
node
.
name
])
self
.
paddle_graph
.
layers
[
layer_id
].
input_shapes
=
{
"x"
:
x_shape
,
"y"
:
y_shape
}
self
.
paddle_graph
.
layers
[
layer_id
].
input_shapes
=
{
"x"
:
x_shape
,
"y"
:
y_shape
}
def
bool_map
(
self
,
node
):
op_type
=
self
.
bool_ops
[
node
.
layer_type
]
self
.
elementwise_map
(
node
,
op_type
)
node
.
set_dtype
(
"bool"
)
def
Placeholder
(
self
,
node
):
def
Placeholder
(
self
,
node
):
shape
=
node
.
out_shapes
[
0
]
shape
=
node
.
out_shapes
[
0
]
...
@@ -213,7 +225,7 @@ class TFOpMapper(OpMapper):
...
@@ -213,7 +225,7 @@ class TFOpMapper(OpMapper):
return
return
self
.
params
[
node
.
name
]
=
node
.
value
self
.
params
[
node
.
name
]
=
node
.
value
self
.
paddle_graph
.
add_layer
(
layer_id
=
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.static.create_parameter"
,
kernel
=
"paddle.static.create_parameter"
,
inputs
=
{},
inputs
=
{},
outputs
=
[
node
.
name
],
outputs
=
[
node
.
name
],
...
@@ -221,6 +233,7 @@ class TFOpMapper(OpMapper):
...
@@ -221,6 +233,7 @@ class TFOpMapper(OpMapper):
shape
=
shape
,
shape
=
shape
,
name
=
string
(
node
.
name
),
name
=
string
(
node
.
name
),
default_initializer
=
"paddle.nn.initializer.Constant(value=0.0)"
)
default_initializer
=
"paddle.nn.initializer.Constant(value=0.0)"
)
self
.
params_output2id
[
node
.
name
]
=
layer_id
def
Transpose
(
self
,
node
):
def
Transpose
(
self
,
node
):
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
])
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
])
...
@@ -763,11 +776,17 @@ class TFOpMapper(OpMapper):
...
@@ -763,11 +776,17 @@ class TFOpMapper(OpMapper):
data_format
=
node
.
get_attr
(
"data_format"
).
decode
()
data_format
=
node
.
get_attr
(
"data_format"
).
decode
()
pad_mode
=
node
.
get_attr
(
"padding"
).
decode
()
pad_mode
=
node
.
get_attr
(
"padding"
).
decode
()
self
.
paddle_graph
.
add_layer
(
if
len
(
kernel
.
outputs
)
==
1
:
kernel
=
"paddle.transpose"
,
self
.
params
[
kernel
.
name
]
=
numpy
.
transpose
(
self
.
params
[
kernel
.
name
],
inputs
=
{
"x"
:
kernel
.
name
},
(
2
,
3
,
0
,
1
))
outputs
=
[
kernel
.
name
],
layer
=
self
.
paddle_graph
.
layers
[
self
.
params_output2id
[
kernel
.
name
]]
perm
=
[
2
,
3
,
0
,
1
])
layer
.
attrs
[
"shape"
]
=
self
.
params
[
kernel
.
name
].
shape
else
:
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.transpose"
,
inputs
=
{
"x"
:
kernel
.
name
},
outputs
=
[
kernel
.
name
],
perm
=
[
2
,
3
,
0
,
1
])
input_name
=
input
.
name
input_name
=
input
.
name
if
data_format
==
"NHWC"
:
if
data_format
==
"NHWC"
:
...
...
x2paddle/optimizer/elimination/dygraph/transpose_elimination.py
浏览文件 @
42dc4e92
...
@@ -178,13 +178,13 @@ class DygraphTransposeElimination(FuseBase):
...
@@ -178,13 +178,13 @@ class DygraphTransposeElimination(FuseBase):
if
_graph
.
layers
[
ipt
].
outputs
[
if
_graph
.
layers
[
ipt
].
outputs
[
output_index
]
==
_graph
.
layers
[
current_id
].
inputs
[
output_index
]
==
_graph
.
layers
[
current_id
].
inputs
[
'x'
]:
'x'
]:
if
l
en
(
x_shape
)
<=
1
:
if
l
ist
(
x_shape
)
==
[
1
]
or
len
(
x_shape
)
<
1
:
elementwise_layers
.
append
(
current_id
)
elementwise_layers
.
append
(
current_id
)
continue
continue
elif
_graph
.
layers
[
ipt
].
outputs
[
elif
_graph
.
layers
[
ipt
].
outputs
[
output_index
]
==
_graph
.
layers
[
current_id
].
inputs
[
output_index
]
==
_graph
.
layers
[
current_id
].
inputs
[
'y'
]:
'y'
]:
if
l
en
(
y_shape
)
<=
1
:
if
l
ist
(
y_shape
)
==
[
1
]
or
len
(
y_shape
)
<
1
:
elementwise_layers
.
append
(
current_id
)
elementwise_layers
.
append
(
current_id
)
continue
continue
else
:
else
:
...
@@ -279,11 +279,6 @@ class DygraphTransposeElimination(FuseBase):
...
@@ -279,11 +279,6 @@ class DygraphTransposeElimination(FuseBase):
for
layer_id
in
list
(
set
(
optimized_concat_layers
)):
for
layer_id
in
list
(
set
(
optimized_concat_layers
)):
axis
=
graph
.
layers
[
layer_id
].
attrs
.
get
(
'axis'
,
0
)
axis
=
graph
.
layers
[
layer_id
].
attrs
.
get
(
'axis'
,
0
)
graph
.
layers
[
layer_id
].
attrs
[
'axis'
]
=
[
0
,
2
,
3
,
1
][
axis
]
graph
.
layers
[
layer_id
].
attrs
[
'axis'
]
=
[
0
,
2
,
3
,
1
][
axis
]
for
layer_id
in
list
(
set
(
optimized_elementwise_layers
)):
axis
=
graph
.
layers
[
layer_id
].
attrs
.
get
(
'axis'
,
-
1
)
graph
.
layers
[
layer_id
].
attrs
[
'axis'
]
=
[
0
,
2
,
3
,
1
][
axis
]
if
graph
.
layers
[
layer_id
].
kernel
==
"paddle.add"
:
graph
.
layers
[
layer_id
].
kernel
=
"fluid.layers.elementwise_add"
current_transpose_num
=
self
.
get_transpose_num
(
graph
)
current_transpose_num
=
self
.
get_transpose_num
(
graph
)
print
(
print
(
...
...
x2paddle/optimizer/elimination/static/transpose_elimination.py
浏览文件 @
42dc4e92
...
@@ -178,13 +178,13 @@ class StaticTransposeElimination(FuseBase):
...
@@ -178,13 +178,13 @@ class StaticTransposeElimination(FuseBase):
if
_graph
.
layers
[
ipt
].
outputs
[
if
_graph
.
layers
[
ipt
].
outputs
[
output_index
]
==
_graph
.
layers
[
current_id
].
inputs
[
output_index
]
==
_graph
.
layers
[
current_id
].
inputs
[
'x'
]:
'x'
]:
if
l
en
(
x_shape
)
<=
1
:
if
l
ist
(
x_shape
)
==
[
1
]
or
len
(
x_shape
)
<
1
:
elementwise_layers
.
append
(
current_id
)
elementwise_layers
.
append
(
current_id
)
continue
continue
elif
_graph
.
layers
[
ipt
].
outputs
[
elif
_graph
.
layers
[
ipt
].
outputs
[
output_index
]
==
_graph
.
layers
[
current_id
].
inputs
[
output_index
]
==
_graph
.
layers
[
current_id
].
inputs
[
'y'
]:
'y'
]:
if
l
en
(
y_shape
)
<=
1
:
if
l
ist
(
y_shape
)
==
[
1
]
or
len
(
y_shape
)
<
1
:
elementwise_layers
.
append
(
current_id
)
elementwise_layers
.
append
(
current_id
)
continue
continue
else
:
else
:
...
@@ -279,11 +279,6 @@ class StaticTransposeElimination(FuseBase):
...
@@ -279,11 +279,6 @@ class StaticTransposeElimination(FuseBase):
for
layer_id
in
list
(
set
(
optimized_concat_layers
)):
for
layer_id
in
list
(
set
(
optimized_concat_layers
)):
axis
=
graph
.
layers
[
layer_id
].
attrs
.
get
(
'axis'
,
0
)
axis
=
graph
.
layers
[
layer_id
].
attrs
.
get
(
'axis'
,
0
)
graph
.
layers
[
layer_id
].
attrs
[
'axis'
]
=
[
0
,
2
,
3
,
1
][
axis
]
graph
.
layers
[
layer_id
].
attrs
[
'axis'
]
=
[
0
,
2
,
3
,
1
][
axis
]
for
layer_id
in
list
(
set
(
optimized_elementwise_layers
)):
axis
=
graph
.
layers
[
layer_id
].
attrs
.
get
(
'axis'
,
-
1
)
graph
.
layers
[
layer_id
].
attrs
[
'axis'
]
=
[
0
,
2
,
3
,
1
][
axis
]
if
graph
.
layers
[
layer_id
].
kernel
==
"paddle.add"
:
graph
.
layers
[
layer_id
].
kernel
=
"fluid.layers.elementwise_add"
current_transpose_num
=
self
.
get_transpose_num
(
graph
)
current_transpose_num
=
self
.
get_transpose_num
(
graph
)
print
(
print
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录