Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
c4714f3f
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看板
提交
c4714f3f
编写于
8月 03, 2020
作者:
M
mamingjie-China
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add Tile and Range
上级
e5f64f3e
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
70 addition
and
10 deletion
+70
-10
x2paddle/op_mapper/tf_op_mapper_nhwc.py
x2paddle/op_mapper/tf_op_mapper_nhwc.py
+70
-10
未找到文件。
x2paddle/op_mapper/tf_op_mapper_nhwc.py
浏览文件 @
c4714f3f
...
@@ -308,6 +308,10 @@ class TFOpMapperNHWC(OpMapper):
...
@@ -308,6 +308,10 @@ class TFOpMapperNHWC(OpMapper):
dilations
=
node
.
get_attr
(
"dilations"
)
dilations
=
node
.
get_attr
(
"dilations"
)
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
()
if
data_format
==
"NHWC"
:
n
,
c
,
h
,
w
=
input
.
out_shapes
[
0
]
else
:
n
,
h
,
w
,
c
=
input
.
out_shapes
[
0
]
if
kernel
.
layer_type
==
'Const'
:
if
kernel
.
layer_type
==
'Const'
:
kernel_value
=
kernel
.
value
kernel_value
=
kernel
.
value
...
@@ -334,6 +338,16 @@ class TFOpMapperNHWC(OpMapper):
...
@@ -334,6 +338,16 @@ class TFOpMapperNHWC(OpMapper):
perm
=
[
0
,
3
,
1
,
2
])
perm
=
[
0
,
3
,
1
,
2
])
input_name
=
transpose_name
input_name
=
transpose_name
if
c
==
-
1
:
attr
=
{
"shape"
:
[
0
,
k_size
[
2
],
0
,
0
]}
node
.
fluid_code
.
add_layer
(
"reshape"
,
inputs
=
input
,
output
=
input
,
param_attr
=
attr
)
program
.
add_layer
(
kernel
=
"fluid.layers.reshape"
,
inputs
=
{
"x"
:
input_name
},
outputs
=
[
input_name
],
shape
=
[
0
,
k_size
[
2
],
0
,
0
])
program
.
add_layer
(
program
.
add_layer
(
kernel
=
"fluid.layers.conv2d"
,
kernel
=
"fluid.layers.conv2d"
,
inputs
=
{
"input"
:
input_name
},
inputs
=
{
"input"
:
input_name
},
...
@@ -701,7 +715,7 @@ class TFOpMapperNHWC(OpMapper):
...
@@ -701,7 +715,7 @@ class TFOpMapperNHWC(OpMapper):
if
len
(
new_axes
)
>
0
:
if
len
(
new_axes
)
>
0
:
program
.
add_layer
(
program
.
add_layer
(
kernel
=
"fluid.layers.unsqueeze"
,
kernel
=
"fluid.layers.unsqueeze"
,
inputs
=
{
"
x
"
:
node
.
name
},
inputs
=
{
"
input
"
:
node
.
name
},
outputs
=
[
node
.
name
],
outputs
=
[
node
.
name
],
axes
=
new_axes
)
axes
=
new_axes
)
if
len
(
shrink_axes
)
>
0
:
if
len
(
shrink_axes
)
>
0
:
...
@@ -710,7 +724,7 @@ class TFOpMapperNHWC(OpMapper):
...
@@ -710,7 +724,7 @@ class TFOpMapperNHWC(OpMapper):
else
:
else
:
program
.
add_layer
(
program
.
add_layer
(
kernel
=
"fluid.layers.unsqueeze"
,
kernel
=
"fluid.layers.unsqueeze"
,
inputs
=
{
"
x
"
:
node
.
name
},
inputs
=
{
"
input
"
:
node
.
name
},
outputs
=
[
node
.
name
],
outputs
=
[
node
.
name
],
axes
=
new_axes
)
axes
=
new_axes
)
...
@@ -741,14 +755,16 @@ class TFOpMapperNHWC(OpMapper):
...
@@ -741,14 +755,16 @@ class TFOpMapperNHWC(OpMapper):
begin
=
begin
.
value
.
tolist
()
begin
=
begin
.
value
.
tolist
()
attrs
[
'offsets'
]
=
begin
attrs
[
'offsets'
]
=
begin
else
:
else
:
shape
=
begin
.
out_shapes
[
0
]
# shape = begin.out_shapes[0]
reshape_name
=
gen_name
(
"slice"
,
"reshape"
)
# reshape_name = gen_name("slice", "reshape")
program
.
add_layer
(
# program.add_layer(
kernel
=
"fluid.layers.reshape"
,
# kernel="fluid.layers.reshape",
inputs
=
{
"x"
:
begin
.
name
},
# inputs={"x": begin.name},
outputs
=
[
reshape_name
],
# outputs=[reshape_name],
shape
=
shape
)
# shape=shape)
inputs
[
'offsets'
]
=
reshape_name
# inputs['offsets'] = reshape_name
begin
=
self
.
decoder
.
infer_tensor
(
begin
).
tolist
()
attrs
[
'offsets'
]
=
begin
if
size
.
layer_type
==
"Const"
:
if
size
.
layer_type
==
"Const"
:
size
=
size
.
value
.
tolist
()
size
=
size
.
value
.
tolist
()
attrs
[
'shape'
]
=
size
attrs
[
'shape'
]
=
size
...
@@ -966,3 +982,47 @@ class TFOpMapperNHWC(OpMapper):
...
@@ -966,3 +982,47 @@ class TFOpMapperNHWC(OpMapper):
inputs
=
{
"x"
:
node
.
name
},
inputs
=
{
"x"
:
node
.
name
},
outputs
=
[
node
.
name
],
outputs
=
[
node
.
name
],
perm
=
[
0
,
2
,
3
,
1
])
perm
=
[
0
,
2
,
3
,
1
])
def
Tile
(
self
,
node
):
input
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
],
copy
=
True
)
expand_times
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
1
],
copy
=
True
)
inputs
=
{
"x"
:
input
.
name
}
attr
=
dict
()
if
expand_times
.
layer_type
==
"Const"
:
expand_times
=
expand_times
.
value
.
tolist
()
attr
[
"expand_times"
]
=
expand_times
else
:
inputs
[
"expand_times"
]
=
expand_times
.
name
program
.
add_layer
(
kernel
=
"fluid.layers.expand"
,
inputs
=
inputs
,
outputs
=
[
node
.
name
],
**
attr
)
def
Range
(
self
,
node
):
start
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
0
],
copy
=
True
)
limit
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
1
],
copy
=
True
)
delta
=
self
.
graph
.
get_node
(
node
.
layer
.
input
[
2
],
copy
=
True
)
inputs
=
dict
()
attr
=
dict
()
if
start
.
layer_type
==
"Const"
:
attr
[
"start"
]
=
start
.
value
else
:
inputs
[
"start"
]
=
start
.
name
if
limit
.
layer_type
==
"Const"
:
attr
[
"end"
]
=
limit
.
value
else
:
inputs
[
"end"
]
=
limit
.
name
if
delta
.
layer_type
==
"Const"
:
attr
[
"step"
]
=
delta
.
value
else
:
inputs
[
"step"
]
=
delta
.
name
attr
[
"dtype"
]
=
string
(
node
.
dtype
)
program
.
add_layer
(
kernel
=
"fluid.layers.range"
,
inputs
=
inputs
,
outputs
=
[
node
.
name
],
**
attr
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录