Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
1adb262a
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
403
Star
4705
Fork
582
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
MegEngine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
1adb262a
编写于
7月 04, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(dnn/naive): fix midout for pooling
GitOrigin-RevId: 4edd99f3ecb3f96275fcd139076d63181487e8ed
上级
32d7f25b
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
58 addition
and
58 deletion
+58
-58
dnn/src/naive/pooling/opr_impl.cpp
dnn/src/naive/pooling/opr_impl.cpp
+58
-58
未找到文件。
dnn/src/naive/pooling/opr_impl.cpp
浏览文件 @
1adb262a
...
...
@@ -370,65 +370,67 @@ void pooling_backward_max_impl(const ctype* __restrict src,
}
}
}
//
anonymous
namespace
}
// namespace
namespace
megdnn
{
namespace
naive
{
void
PoolingForwardImpl
::
exec
(
_megdnn_tensor_in
src
,
_megdnn_tensor_out
dst
,
_megdnn_workspace
workspace
)
{
MIDOUT_BEGIN
(
megdnn_naive_pooling
)
{
check_exec
(
src
.
layout
,
dst
.
layout
,
workspace
.
size
);
size_t
c_pos
,
spatial_pos
,
batch_pos
=
0
;
if
(
param
().
format
==
Param
::
Format
::
NCHW
||
param
().
format
==
Param
::
Format
::
NCHW4
||
param
().
format
==
Param
::
Format
::
NCHW88
||
param
().
format
==
Param
::
Format
::
NCHW44
||
param
().
format
==
Param
::
Format
::
NCHW32
)
{
c_pos
=
1
;
spatial_pos
=
2
;
}
else
if
(
param
().
format
==
Param
::
Format
::
NHWC
)
{
c_pos
=
3
;
spatial_pos
=
1
;
}
else
if
(
param
().
format
==
Param
::
Format
::
CHWN4
)
{
c_pos
=
0
;
spatial_pos
=
1
;
batch_pos
=
3
;
}
else
{
megdnn_assert
(
param
().
format
==
Param
::
Format
::
NHWCD4
);
c_pos
=
2
;
spatial_pos
=
1
;
}
size_t
N
=
src
.
layout
.
shape
[
batch_pos
],
C
=
src
.
layout
.
shape
[
c_pos
],
IH
=
src
.
layout
.
shape
[
spatial_pos
+
0
],
IW
=
src
.
layout
.
shape
[
spatial_pos
+
1
];
size_t
OH
=
dst
.
layout
.
shape
[
spatial_pos
+
0
],
OW
=
dst
.
layout
.
shape
[
spatial_pos
+
1
];
if
(
param
().
format
==
Param
::
Format
::
NHWCD4
)
{
C
*=
4
;
IW
=
src
.
layout
.
shape
[
spatial_pos
+
2
];
OW
=
dst
.
layout
.
shape
[
spatial_pos
+
2
];
}
if
(
param
().
format
==
Param
::
Format
::
NCHW4
||
param
().
format
==
Param
::
Format
::
NCHW44
||
param
().
format
==
Param
::
Format
::
CHWN4
)
{
C
*=
4
;
}
if
(
param
().
format
==
Param
::
Format
::
NCHW88
)
{
C
*=
8
;
}
if
(
param
().
format
==
Param
::
Format
::
NCHW32
)
{
C
*=
32
;
}
size_t
PH
=
param
().
pad_h
,
PW
=
param
().
pad_w
;
size_t
FH
=
param
().
window_h
,
FW
=
param
().
window_w
;
size_t
SH
=
param
().
stride_h
,
SW
=
param
().
stride_w
;
#define DISPATCH_WITH_POOLER_AND_IDX_GETTER(Pooler, IdxGetter) \
MEGDNN_DISPATCH_CPU_KERN( \
static_cast<naive::HandleImpl*>(handle()), \
pooling_forward_impl<Pooler MEGDNN_COMMA IdxGetter>( \
sptr, dptr, src.layout.dtype, N, C, IH, IW, OH, OW, PH, \
PW, SH, SW, FH, FW));
check_exec
(
src
.
layout
,
dst
.
layout
,
workspace
.
size
);
size_t
c_pos
,
spatial_pos
,
batch_pos
=
0
;
if
(
param
().
format
==
Param
::
Format
::
NCHW
||
param
().
format
==
Param
::
Format
::
NCHW4
||
param
().
format
==
Param
::
Format
::
NCHW88
||
param
().
format
==
Param
::
Format
::
NCHW44
||
param
().
format
==
Param
::
Format
::
NCHW32
)
{
c_pos
=
1
;
spatial_pos
=
2
;
}
else
if
(
param
().
format
==
Param
::
Format
::
NHWC
)
{
c_pos
=
3
;
spatial_pos
=
1
;
}
else
if
(
param
().
format
==
Param
::
Format
::
CHWN4
)
{
c_pos
=
0
;
spatial_pos
=
1
;
batch_pos
=
3
;
}
else
{
megdnn_assert
(
param
().
format
==
Param
::
Format
::
NHWCD4
);
c_pos
=
2
;
spatial_pos
=
1
;
}
size_t
N
=
src
.
layout
.
shape
[
batch_pos
],
C
=
src
.
layout
.
shape
[
c_pos
],
IH
=
src
.
layout
.
shape
[
spatial_pos
+
0
],
IW
=
src
.
layout
.
shape
[
spatial_pos
+
1
];
size_t
OH
=
dst
.
layout
.
shape
[
spatial_pos
+
0
],
OW
=
dst
.
layout
.
shape
[
spatial_pos
+
1
];
if
(
param
().
format
==
Param
::
Format
::
NHWCD4
)
{
C
*=
4
;
IW
=
src
.
layout
.
shape
[
spatial_pos
+
2
];
OW
=
dst
.
layout
.
shape
[
spatial_pos
+
2
];
}
if
(
param
().
format
==
Param
::
Format
::
NCHW4
||
param
().
format
==
Param
::
Format
::
NCHW44
||
param
().
format
==
Param
::
Format
::
CHWN4
)
{
C
*=
4
;
}
if
(
param
().
format
==
Param
::
Format
::
NCHW88
)
{
C
*=
8
;
}
if
(
param
().
format
==
Param
::
Format
::
NCHW32
)
{
C
*=
32
;
}
size_t
PH
=
param
().
pad_h
,
PW
=
param
().
pad_w
;
size_t
FH
=
param
().
window_h
,
FW
=
param
().
window_w
;
size_t
SH
=
param
().
stride_h
,
SW
=
param
().
stride_w
;
#define DISPATCH_WITH_POOLER_AND_IDX_GETTER(Pooler, IdxGetter) \
MIDOUT_BEGIN(megdnn_naive_pooling, midout_iv(#Pooler #IdxGetter##_hash)) { \
MEGDNN_DISPATCH_CPU_KERN( \
static_cast<naive::HandleImpl*>(handle()), \
pooling_forward_impl<Pooler MEGDNN_COMMA IdxGetter>( \
sptr, dptr, src.layout.dtype, N, C, IH, IW, OH, OW, \
PH, PW, SH, SW, FH, FW)); \
} \
MIDOUT_END();
#define DISPATCH_WITH_POOLER(Pooler) \
switch (param().format) { \
...
...
@@ -484,14 +486,12 @@ void PoolingForwardImpl::exec(_megdnn_tensor_in src, _megdnn_tensor_out dst,
} \
} \
}
MEGDNN_FOREACH_COMPUTING_DTYPE
(
cb
)
MEGDNN_FOREACH_QUANTIZED_DTYPE
(
cb
)
MEGDNN_FOREACH_COMPUTING_DTYPE
(
cb
)
MEGDNN_FOREACH_QUANTIZED_DTYPE
(
cb
)
#undef cb
#undef DISPATCH_WITH_POOLER_AND_IDX_GETTER
#undef DISPATCH_WITH_POOLER
megdnn_assert_internal
(
0
);
}
MIDOUT_END
();
megdnn_assert_internal
(
0
);
}
WorkspaceBundle
PoolingBackwardImpl
::
get_workspace_bundle
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录