Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
X2Paddle
提交
edb4bde7
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看板
提交
edb4bde7
编写于
2月 02, 2021
作者:
S
SunAhong1993
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add pooling round_mode
上级
0c3d8fe5
变更
5
展开全部
显示空白变更内容
内联
并排
Showing
5 changed file
with
1123 addition
and
806 deletion
+1123
-806
x2paddle/decoder/caffe.proto
x2paddle/decoder/caffe.proto
+5
-0
x2paddle/decoder/caffe_pb2.py
x2paddle/decoder/caffe_pb2.py
+1095
-796
x2paddle/decoder/caffe_shape_inference.py
x2paddle/decoder/caffe_shape_inference.py
+10
-1
x2paddle/op_mapper/dygraph/caffe2paddle/caffe_op_mapper.py
x2paddle/op_mapper/dygraph/caffe2paddle/caffe_op_mapper.py
+7
-5
x2paddle/op_mapper/static/caffe2paddle/caffe_op_mapper.py
x2paddle/op_mapper/static/caffe2paddle/caffe_op_mapper.py
+6
-4
未找到文件。
x2paddle/decoder/caffe.proto
浏览文件 @
edb4bde7
...
...
@@ -1378,6 +1378,11 @@ message PoolingParameter {
// If global_pooling then it will pool over the size of the bottom by doing
// kernel_h = bottom->height and kernel_w = bottom->width
optional
bool
global_pooling
=
12
[
default
=
false
];
enum
RoundMode
{
CEIL
=
0
;
FLOOR
=
1
;
}
optional
RoundMode
round_mode
=
13
[
default
=
CEIL
];
}
message
PowerParameter
{
...
...
x2paddle/decoder/caffe_pb2.py
浏览文件 @
edb4bde7
此差异已折叠。
点击以展开。
x2paddle/decoder/caffe_shape_inference.py
浏览文件 @
edb4bde7
...
...
@@ -115,6 +115,12 @@ def shape_pooling(layer, input_shape):
method
=
math
.
ceil
else
:
method
=
math
.
floor
if
not
hasattr
(
params
,
'ceil_mode'
):
round_mode
=
getattr
(
params
,
'round_mode'
,
0
)
if
round_mode
==
1
:
method
=
math
.
floor
else
:
method
=
math
.
ceil
return
get_strided_kernel_output_shape
(
params
,
input_shape
[
0
],
method
)
...
...
@@ -240,7 +246,9 @@ def shape_reshape(layer, input_shape):
params
=
layer
.
reshape_param
axis
=
params
.
axis
if
hasattr
(
params
,
'axis'
)
else
0
num_axes
=
params
.
num_axes
if
hasattr
(
params
,
'num_axes'
)
else
-
1
is_unknow_batch
=
False
if
inshape
[
0
]
==
-
1
:
is_unknow_batch
=
True
inshape
[
0
]
=
1
input_count
=
count
(
inshape
)
...
...
@@ -310,6 +318,7 @@ def shape_reshape(layer, input_shape):
output_count
=
count
(
output_shape
)
assert
output_count
==
input_count
,
"[Reshape]output count[%d] must match input count[%d]"
%
(
output_count
,
input_count
)
if
is_unknow_batch
:
output_shape
[
0
]
=
-
1
return
[
output_shape
]
...
...
x2paddle/op_mapper/dygraph/caffe2paddle/caffe_op_mapper.py
浏览文件 @
edb4bde7
...
...
@@ -358,7 +358,9 @@ class CaffeOpMapper(OpMapper):
output_name
=
node
.
layer_name
layer_outputs
=
[
pool2d_name
,
output_name
]
params
=
node
.
layer
.
pooling_param
ceil_mode
=
getattr
(
params
,
"ceil_mod"
,
True
)
ceil_mode
=
getattr
(
params
,
"ceil_mode"
,
True
)
if
not
hasattr
(
params
,
'ceil_mode'
):
ceil_mode
=
True
if
getattr
(
params
,
"round_mode"
,
0
)
==
0
else
False
global_pool
=
getattr
(
params
,
"global_pooling"
,
False
)
kernel_default
=
[
1
,
1
]
channel
,
kernel
,
stride
,
pad
,
dilation
,
group
=
_get_kernel_parameters
(
...
...
@@ -635,7 +637,7 @@ class CaffeOpMapper(OpMapper):
"paddle.scale"
,
inputs
=
{
"x"
:
input1_name
},
outputs
=
[
node
.
layer_name
+
'_mul1'
],
scale
=
coeff
[
2
])
scale
=
coeff
[
1
])
inputs_dict
=
{}
inputs_dict
[
'x'
]
=
node
.
layer_name
+
'_mul0'
inputs_dict
[
'y'
]
=
node
.
layer_name
+
'_mul1'
...
...
@@ -972,12 +974,12 @@ class CaffeOpMapper(OpMapper):
# operation = MEAN
else
:
layer_attrs
=
{
"
dim
"
:
dim
[
axis
:],
"keep
_
dim"
:
False
,
"
axis
"
:
dim
[
axis
:],
"keepdim"
:
False
,
}
self
.
paddle_graph
.
add_layer
(
"paddle.mean"
,
inputs
=
{
"
input
"
:
input
.
name
},
inputs
=
{
"
x
"
:
input
.
name
},
outputs
=
[
node
.
layer_name
],
**
layer_attrs
)
self
.
paddle_graph
.
add_layer
(
...
...
x2paddle/op_mapper/static/caffe2paddle/caffe_op_mapper.py
浏览文件 @
edb4bde7
...
...
@@ -395,6 +395,8 @@ class CaffeOpMapper(OpMapper):
def
Pooling
(
self
,
node
):
params
=
node
.
layer
.
pooling_param
ceil_mode
=
getattr
(
params
,
'ceil_mode'
,
True
)
if
not
hasattr
(
params
,
'ceil_mode'
):
ceil_mode
=
True
if
getattr
(
params
,
"round_mode"
,
0
)
==
0
else
False
global_pool
=
getattr
(
params
,
'global_pooling'
,
False
)
kernel_default
=
[
1
,
1
]
channel
,
kernel
,
stride
,
pad
,
dilation
,
group
=
_get_kernel_parameters
(
...
...
@@ -679,7 +681,7 @@ class CaffeOpMapper(OpMapper):
"paddle.scale"
,
inputs
=
{
"x"
:
input1_name
},
outputs
=
[
node
.
name
+
'_mul1'
],
scale
=
coeff
[
2
])
scale
=
coeff
[
1
])
inputs_dict
=
{}
inputs_dict
[
'x'
]
=
node
.
name
+
'_mul0'
inputs_dict
[
'y'
]
=
node
.
name
+
'_mul1'
...
...
@@ -1024,12 +1026,12 @@ class CaffeOpMapper(OpMapper):
# operation = MEAN
else
:
layer_attrs
=
{
"
dim
"
:
dim
[
axis
:],
"keep
_
dim"
:
False
,
"
axis
"
:
dim
[
axis
:],
"keepdim"
:
False
,
}
self
.
paddle_graph
.
add_layer
(
"paddle.mean"
,
inputs
=
{
"
input
"
:
input
.
name
},
inputs
=
{
"
x
"
:
input
.
name
},
outputs
=
[
node
.
name
],
**
layer_attrs
)
self
.
paddle_graph
.
add_layer
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录