Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
9277f0bc
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看板
未验证
提交
9277f0bc
编写于
6月 03, 2021
作者:
W
WJJ1995
提交者:
GitHub
6月 03, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix caffe bug && Add onnx 3d interpolate support (#611)
* fix caffe kernel_size=0 bug * add onnx 3d interpolate support
上级
66b2a048
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
81 addition
and
33 deletion
+81
-33
x2paddle/op_mapper/caffe2paddle/caffe_op_mapper.py
x2paddle/op_mapper/caffe2paddle/caffe_op_mapper.py
+4
-4
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
+77
-29
未找到文件。
x2paddle/op_mapper/caffe2paddle/caffe_op_mapper.py
浏览文件 @
9277f0bc
...
...
@@ -62,15 +62,15 @@ def _get_kernel_parameters(kind, params):
"Convolution"
,
"Pooling"
,
"Deconvolution"
,
"ConvolutionDepthwise"
]
[
k_h
,
k_w
]
=
[
1
,
1
]
if
isinstance
(
params
.
kernel_size
,
numbers
.
Number
):
if
params
.
kernel_h
>
0
or
params
.
kernel_w
>
0
:
k_h
=
params
.
kernel_h
k_w
=
params
.
kernel_w
elif
isinstance
(
params
.
kernel_size
,
numbers
.
Number
):
[
k_h
,
k_w
]
=
[
params
.
kernel_size
]
*
2
elif
len
(
params
.
kernel_size
)
>
0
:
k_h
=
params
.
kernel_h
if
params
.
kernel_h
>
0
else
params
.
kernel_size
[
0
]
k_w
=
params
.
kernel_w
if
params
.
kernel_w
>
0
else
params
.
kernel_size
[
len
(
params
.
kernel_size
)
-
1
]
elif
params
.
kernel_h
>
0
or
params
.
kernel_w
>
0
:
k_h
=
params
.
kernel_h
k_w
=
params
.
kernel_w
[
s_h
,
s_w
]
=
[
1
,
1
]
if
isinstance
(
params
.
stride
,
numbers
.
Number
):
[
s_h
,
s_w
]
=
[
params
.
stride
]
*
2
...
...
x2paddle/op_mapper/onnx2paddle/opset9/opset.py
浏览文件 @
9277f0bc
...
...
@@ -309,6 +309,51 @@ class OpSet9():
elif
len
(
node
.
layer
.
input
)
==
4
:
# opset 11
val_sizes
=
self
.
graph
.
get_input_node
(
node
,
idx
=
3
,
copy
=
True
)
val_x_shape
=
val_x
.
out_shapes
[
0
]
if
len
(
val_x_shape
)
==
3
:
var_n
,
var_hw
=
val_sizes
.
name
+
'_n'
,
val_sizes
.
name
+
'_hw'
self
.
paddle_graph
.
add_layer
(
'paddle.split'
,
inputs
=
{
"x"
:
val_sizes
.
name
},
outputs
=
[
var_n
,
var_hw
],
num_or_sections
=
[
1
,
2
],
axis
=
0
)
self
.
paddle_graph
.
add_layer
(
"paddle.cast"
,
inputs
=
{
"x"
:
var_hw
},
outputs
=
[
var_hw
],
dtype
=
string
(
'int32'
))
inputs
[
'size'
]
=
var_hw
attrs
=
{
"align_corners"
:
False
,
"mode"
:
string
(
node
.
get_attr
(
'mode'
,
'nearest'
))
}
mode
=
node
.
get_attr
(
'mode'
,
'nearest'
)
if
mode
==
"linear"
:
attrs
[
"mode"
]
=
string
(
"bilinear"
)
if
node
.
get_attr
(
'coordinate_transformation_mode'
,
'half_pixel'
)
==
'pytorch_half_pixel'
:
attrs
[
"align_corners"
]
=
False
attrs
[
"align_mode"
]
=
0
if
node
.
get_attr
(
'coordinate_transformation_mode'
,
'half_pixel'
)
==
'align_corners'
:
attrs
[
"align_corners"
]
=
True
self
.
paddle_graph
.
add_layer
(
'paddle.unsqueeze'
,
inputs
=
{
"x"
:
val_x
.
name
},
outputs
=
[
val_x
.
name
],
axis
=
0
)
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.nn.functional.interpolate"
,
inputs
=
inputs
,
outputs
=
[
node
.
name
],
**
attrs
)
self
.
paddle_graph
.
add_layer
(
'paddle.squeeze'
,
inputs
=
{
"x"
:
node
.
name
},
outputs
=
[
node
.
name
],
axis
=
0
)
else
:
var_nc
,
var_hw
=
val_sizes
.
name
+
'_nc'
,
val_sizes
.
name
+
'_hw'
self
.
paddle_graph
.
add_layer
(
'paddle.split'
,
...
...
@@ -333,6 +378,9 @@ class OpSet9():
'half_pixel'
)
==
'pytorch_half_pixel'
:
attrs
[
"align_corners"
]
=
False
attrs
[
"align_mode"
]
=
0
if
node
.
get_attr
(
'coordinate_transformation_mode'
,
'half_pixel'
)
==
'align_corners'
:
attrs
[
"align_corners"
]
=
True
self
.
paddle_graph
.
add_layer
(
kernel
=
"paddle.nn.functional.interpolate"
,
inputs
=
inputs
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录