Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
230ab45a
MegEngine
项目概览
MegEngine 天元
/
MegEngine
1 年多 前同步成功
通知
404
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看板
提交
230ab45a
编写于
8月 06, 2020
作者:
M
Megvii Engine Team
提交者:
Xinran Xu
8月 25, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mgb/naive): fix naive convolution no dispatch kernel in handle
GitOrigin-RevId: 4038fe23a452f8455a2f0d7cf91e173e5769d77c
上级
22853fa2
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
60 addition
and
25 deletion
+60
-25
dnn/src/common/conv_bias.cpp
dnn/src/common/conv_bias.cpp
+7
-6
dnn/src/common/conv_bias.h
dnn/src/common/conv_bias.h
+7
-9
dnn/src/common/opr_delegate.cpp
dnn/src/common/opr_delegate.cpp
+13
-5
dnn/src/common/opr_delegate.h
dnn/src/common/opr_delegate.h
+1
-1
dnn/src/naive/batch_conv_bias/opr_impl.cpp
dnn/src/naive/batch_conv_bias/opr_impl.cpp
+3
-2
dnn/src/naive/conv_bias/opr_impl.cpp
dnn/src/naive/conv_bias/opr_impl.cpp
+2
-2
src/core/test/graph/misc.cpp
src/core/test/graph/misc.cpp
+27
-0
未找到文件。
dnn/src/common/conv_bias.cpp
浏览文件 @
230ab45a
...
...
@@ -13,6 +13,7 @@
#include "src/common/conv_bias.h"
#include "megdnn/oprs/nn.h"
#include "src/common/utils.h"
#include "src/common/opr_delegate.h"
namespace
megdnn
{
...
...
@@ -445,13 +446,13 @@ void handle_bias_and_nonlinear(Handle* handle, param::ConvBias args,
//! Only used for naive implementation. DO NOT use the following function in
//! other backends.
void
handle_z_inp_and_activation
(
Handle
*
handle
,
param
::
ConvBias
::
NonlineMode
nonline_mode
,
const
TensorND
&
conv_bias_tensor
,
const
TensorND
&
z_tensor
,
const
TensorND
&
dst_tensor
,
dt_byte
*
workspace_ptr
)
{
void
handle_z_inp_and_activation_naive
(
param
::
ConvBias
::
NonlineMode
nonline_mode
,
const
TensorND
&
conv_bias_tensor
,
const
TensorND
&
z_tensor
,
const
TensorND
&
dst_tensor
,
dt_byte
*
workspace_ptr
)
{
auto
res
=
dst_tensor
,
z_float
=
z_tensor
;
//!create naive inplace handle
auto
handle
=
inplace_cpu_handle
(
2
);
if
(
z_tensor
.
layout
.
ndim
>
0
&&
z_tensor
.
layout
.
dtype
.
category
()
!=
DTypeCategory
::
FLOAT
)
{
dt_byte
*
res_float_workspace_ptr
=
nullptr
,
...
...
dnn/src/common/conv_bias.h
浏览文件 @
230ab45a
...
...
@@ -18,16 +18,14 @@
namespace
megdnn
{
void
handle_bias_and_nonlinear
(
Handle
*
handle
,
param
::
ConvBias
args
,
const
TensorND
*
conv_dst_tensor
,
const
TensorND
*
dst_tensor
,
const
TensorND
*
bias_tensor
);
const
TensorND
*
conv_dst_tensor
,
const
TensorND
*
dst_tensor
,
const
TensorND
*
bias_tensor
);
void
handle_z_inp_and_activation
(
Handle
*
handle
,
param
::
ConvBias
::
NonlineMode
nonline_mode
,
const
TensorND
&
conv_bias_tensor
,
const
TensorND
&
z_tensor
,
const
TensorND
&
dst_tensor
,
dt_byte
*
workspace_ptr
);
void
handle_z_inp_and_activation_naive
(
param
::
ConvBias
::
NonlineMode
nonline_mode
,
const
TensorND
&
conv_bias_tensor
,
const
TensorND
&
z_tensor
,
const
TensorND
&
dst_tensor
,
dt_byte
*
workspace_ptr
);
}
// namespace megdnn
...
...
dnn/src/common/opr_delegate.cpp
浏览文件 @
230ab45a
...
...
@@ -13,8 +13,8 @@
using
namespace
megdnn
;
const
std
::
shared_ptr
<
Handle
>&
megdnn
::
inplace_cpu_handle
()
{
auto
make
=
[]()
{
const
std
::
shared_ptr
<
Handle
>&
megdnn
::
inplace_cpu_handle
(
int
debug_level
)
{
auto
make
=
[](
int
deb_level
)
{
megcoreDeviceHandle_t
dev_handle
;
megcoreCreateDeviceHandle
(
&
dev_handle
,
megcorePlatformCPU
);
megcoreComputingHandle_t
comp_handle
;
...
...
@@ -23,12 +23,20 @@ const std::shared_ptr<Handle>& megdnn::inplace_cpu_handle() {
megcoreDestroyComputingHandle
(
comp_handle
);
megcoreDestroyDeviceHandle
(
dev_handle
);
};
std
::
shared_ptr
<
Handle
>
handle
=
Handle
::
make
(
comp_handle
);
std
::
shared_ptr
<
Handle
>
handle
=
Handle
::
make
(
comp_handle
,
deb_level
);
handle
->
set_destructor
(
destructor
);
return
handle
;
};
static
std
::
shared_ptr
<
Handle
>
handle
=
make
();
return
handle
;
if
(
debug_level
==
0
)
{
static
std
::
shared_ptr
<
Handle
>
handle
=
make
(
0
);
return
handle
;
}
else
if
(
debug_level
==
1
)
{
static
std
::
shared_ptr
<
Handle
>
handle_fallback
=
make
(
1
);
return
handle_fallback
;
}
else
{
static
std
::
shared_ptr
<
Handle
>
handle_naive
=
make
(
2
);
return
handle_naive
;
}
}
// vim: syntax=cpp.doxygen
dnn/src/common/opr_delegate.h
浏览文件 @
230ab45a
...
...
@@ -24,7 +24,7 @@ namespace megdnn {
* Usually used for calling other opr impls from some opr impl. You probably
* want to use CpuOprDelegationStorage instead.
*/
const
std
::
shared_ptr
<
Handle
>&
inplace_cpu_handle
();
const
std
::
shared_ptr
<
Handle
>&
inplace_cpu_handle
(
int
debug_level
=
0
);
/*!
* \brief storage for oprs on inplace CPU handle
...
...
dnn/src/naive/batch_conv_bias/opr_impl.cpp
浏览文件 @
230ab45a
...
...
@@ -104,8 +104,9 @@ void BatchConvBiasForwardImpl::exec(_megdnn_tensor_in src,
}
#undef DISPATCH
#undef DISPATCH_RAW
handle_z_inp_and_activation
(
handle
(),
param
().
nonlineMode
,
sfb
,
z
,
dst
,
reinterpret_cast
<
dt_byte
*>
(
ws
.
get
(
1
)));
MEGDNN_DISPATCH_CPU_KERN_OPR
(
handle_z_inp_and_activation_naive
(
param
().
nonlineMode
,
sfb
,
z
,
dst
,
reinterpret_cast
<
dt_byte
*>
(
ws
.
get
(
1
))));
}
std
::
vector
<
BatchConvBiasForward
::
Algorithm
*>
...
...
dnn/src/naive/conv_bias/opr_impl.cpp
浏览文件 @
230ab45a
...
...
@@ -137,8 +137,8 @@ void ConvBiasForwardImpl::exec(_megdnn_tensor_in src, _megdnn_tensor_in filter,
}
#undef DISPATCH
#undef DISPATCH_RAW
handle_z_inp_and_activation
(
handle
(),
param
().
nonlineMode
,
sfb
,
z
,
dst
,
workspace_ptr
);
MEGDNN_DISPATCH_CPU_KERN_OPR
(
handle_z_inp_and_activation_naive
(
param
().
nonlineMode
,
sfb
,
z
,
dst
,
workspace_ptr
)
);
}
MIDOUT_END
();
}
...
...
src/core/test/graph/misc.cpp
浏览文件 @
230ab45a
...
...
@@ -11,6 +11,7 @@
#include "megbrain/opr/io.h"
#include "megbrain/opr/basic_arith_wrapper.h"
#include "megbrain/opr/dnn/convolution.h"
#include "megbrain/opr/utility.h"
#include "megbrain/opr/blas.h"
#include "megbrain/opr/tensor_manip.h"
...
...
@@ -22,6 +23,7 @@
#include "megbrain/graph/execution_mask.h"
#include "megbrain/utils/timer.h"
#include "megbrain/comp_node_env.h"
#include "megbrain/gopt/inference.h"
#include "megbrain/test/helper.h"
...
...
@@ -1814,4 +1816,29 @@ TEST(TestGraph, OperatorNodeConfigInstanceID) {
}
}
TEST
(
TestGraph
,
NaiveRecord2NCHW44
)
{
auto
cn
=
CompNode
::
load
(
"cpu0"
);
using
ConvParam
=
megdnn
::
ConvBias
::
Param
;
ConvParam
param
;
param
.
sparse
=
ConvParam
::
Sparse
::
DENSE
;
param
.
format
=
ConvParam
::
Format
::
NCHW44
;
HostTensorGenerator
<>
gen
;
auto
host_x
=
gen
({
1
,
2
,
12
,
12
,
4
},
cn
),
host_w
=
gen
({
2
,
2
,
3
,
3
,
4
,
4
},
cn
),
host_b
=
gen
({
1
,
2
,
1
,
1
,
4
},
cn
);
HostTensorND
host_z
;
auto
graph
=
ComputingGraph
::
make
();
auto
x
=
opr
::
Host2DeviceCopy
::
make
(
*
graph
,
host_x
),
w
=
opr
::
Host2DeviceCopy
::
make
(
*
graph
,
host_w
),
b
=
opr
::
Host2DeviceCopy
::
make
(
*
graph
,
host_b
),
z
=
opr
::
ConvBiasForward
::
make
(
x
,
w
,
b
,
param
,
{});
graph
->
options
().
comp_node_seq_record_level
=
2
;
graph
->
options
().
var_sanity_check_first_run
=
false
;
auto
func
=
graph
->
compile
({
make_callback_copy
(
z
,
host_z
)});
ComputingGraph
::
assert_destroy
(
graph
);
host_x
->
copy_from_fixlayout
(
*
gen
(
host_x
->
shape
(),
cn
));
func
->
execute
().
wait
();
}
// vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录