Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
62c6e875
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看板
未验证
提交
62c6e875
编写于
1月 11, 2021
作者:
J
Jason
提交者:
GitHub
1月 11, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #485 from SunAhong1993/tf
更新tf Pad相关op
上级
9be89747
a885ae45
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
11 addition
and
88 deletion
+11
-88
x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py
x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py
+4
-45
x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py
x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py
+7
-43
未找到文件。
x2paddle/op_mapper/dygraph/tf2paddle/tf_op_mapper.py
浏览文件 @
62c6e875
...
...
@@ -642,27 +642,6 @@ class TFOpMapper(OpMapper):
assert
paddings
.
layer_type
==
"Const"
,
"Padding should be Const"
paddings
=
paddings
.
value
.
flatten
().
tolist
()
if
len
(
input
.
out_shapes
[
0
])
==
4
:
if
paddings
[
0
]
+
paddings
[
1
]
+
paddings
[
6
]
+
paddings
[
7
]
==
0
:
new_padding
=
paddings
[
2
:
6
]
transpose_name
=
gen_name
(
"pad"
,
"transpose"
)
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.transpose"
,
inputs
=
{
"x"
:
input
.
name
},
outputs
=
[
transpose_name
],
perm
=
[
0
,
3
,
1
,
2
])
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.nn.functional.pad"
,
inputs
=
{
"x"
:
transpose_name
},
outputs
=
[
node
.
name
],
pad
=
new_padding
)
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.transpose"
,
inputs
=
{
"x"
:
node
.
name
},
outputs
=
[
node
.
name
],
perm
=
[
0
,
2
,
3
,
1
])
return
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.nn.functional.pad"
,
inputs
=
{
"x"
:
input
.
name
},
...
...
@@ -670,31 +649,11 @@ class TFOpMapper(OpMapper):
pad
=
paddings
)
def
MirrorPad
(
self
,
node
):
op_name
=
name_generator
(
"pad"
,
self
.
nn_name2id
)
output_name
=
node
.
name
layer_outputs
=
[
op_name
,
output_name
]
input
=
self
.
graph
.
get_input_node
(
node
,
0
)
paddings
=
self
.
graph
.
get_input_node
(
node
,
1
)
assert
paddings
.
layer_type
==
"Const"
,
"Padding should be Const"
new_paddings
=
numpy
.
flip
(
paddings
.
value
,
0
).
flatten
().
tolist
()
dim
=
int
(
len
(
new_paddings
)
/
2
)
transpose_name
=
gen_name
(
"pad"
,
"transpose"
)
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.transpose"
,
inputs
=
{
"x"
:
input
.
name
},
outputs
=
[
transpose_name
],
perm
=
[
0
,
3
,
1
,
2
])
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.nn.Pad{}D"
.
format
(
dim
),
inputs
=
{
"x"
:
transpose_name
},
outputs
=
layer_outputs
,
pad
=
new_paddings
)
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.transpose"
,
inputs
=
{
"x"
:
node
.
name
},
outputs
=
[
node
.
name
],
perm
=
[
0
,
2
,
3
,
1
])
self
.
Pad
(
node
)
def
PadV2
(
self
,
node
):
self
.
Pad
(
node
)
def
Squeeze
(
self
,
node
):
input
=
self
.
graph
.
get_input_node
(
node
,
0
)
...
...
x2paddle/op_mapper/static/tf2paddle/tf_op_mapper.py
浏览文件 @
62c6e875
...
...
@@ -625,32 +625,11 @@ class TFOpMapper(OpMapper):
shape
=
out_shape
.
tolist
())
def
Pad
(
self
,
node
):
input
=
self
.
graph
.
get_
node
(
node
.
layer
.
input
[
0
]
)
paddings
=
self
.
graph
.
get_
node
(
node
.
layer
.
input
[
1
]
)
input
=
self
.
graph
.
get_
input_node
(
node
,
0
)
paddings
=
self
.
graph
.
get_
input_node
(
node
,
1
)
assert
paddings
.
layer_type
==
"Const"
,
"Padding should be Const"
paddings
=
paddings
.
value
.
flatten
().
tolist
()
if
len
(
input
.
out_shapes
[
0
])
==
4
:
if
paddings
[
0
]
+
paddings
[
1
]
+
paddings
[
6
]
+
paddings
[
7
]
==
0
:
new_padding
=
paddings
[
2
:
6
]
transpose_name
=
gen_name
(
"pad"
,
"transpose"
)
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.transpose"
,
inputs
=
{
"x"
:
input
.
name
},
outputs
=
[
transpose_name
],
perm
=
[
0
,
3
,
1
,
2
])
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.nn.functional.pad"
,
inputs
=
{
"x"
:
transpose_name
},
outputs
=
[
node
.
name
],
pad
=
new_padding
)
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.transpose"
,
inputs
=
{
"x"
:
node
.
name
},
outputs
=
[
node
.
name
],
perm
=
[
0
,
2
,
3
,
1
])
return
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.nn.functional.pad"
,
inputs
=
{
"x"
:
input
.
name
},
...
...
@@ -658,26 +637,11 @@ class TFOpMapper(OpMapper):
pad
=
paddings
)
def
MirrorPad
(
self
,
node
):
input
=
self
.
graph
.
get_input_node
(
node
,
0
)
paddings
=
self
.
graph
.
get_input_node
(
node
,
1
)
assert
paddings
.
layer_type
==
"Const"
,
"Padding should be Const"
new_paddings
=
numpy
.
flip
(
paddings
.
value
,
0
).
flatten
().
tolist
()
transpose_name
=
gen_name
(
"pad"
,
"transpose"
)
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.transpose"
,
inputs
=
{
"x"
:
input
.
name
},
outputs
=
[
transpose_name
],
perm
=
[
0
,
3
,
1
,
2
])
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.nn.functional.pad"
.
format
(
dim
),
inputs
=
{
"x"
:
transpose_name
},
outputs
=
[
node
.
name
],
pad
=
new_paddings
)
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.transpose"
,
inputs
=
{
"x"
:
node
.
name
},
outputs
=
[
node
.
name
],
perm
=
[
0
,
2
,
3
,
1
])
self
.
Pad
(
node
)
def
PadV2
(
self
,
node
):
self
.
Pad
(
node
)
def
Squeeze
(
self
,
node
):
input
=
self
.
graph
.
get_input_node
(
node
,
0
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录