Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
f470df4f
MegEngine
项目概览
MegEngine 天元
/
MegEngine
10 个月 前同步成功
通知
392
Star
4702
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看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f470df4f
编写于
11月 25, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mgb/opr): fix convbias with no bias when weight preprocess
GitOrigin-RevId: 8837ad539cf4bd9f99a546996ee91cad31a03766
上级
6c4841e8
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
18 addition
and
8 deletion
+18
-8
src/core/test/graph/misc.cpp
src/core/test/graph/misc.cpp
+3
-2
src/opr/impl/dnn/convolution.cpp
src/opr/impl/dnn/convolution.cpp
+15
-6
未找到文件。
src/core/test/graph/misc.cpp
浏览文件 @
f470df4f
...
@@ -1976,7 +1976,6 @@ typename DnnOp::Algorithm* try_find_any_bias_preprocess_algo(
...
@@ -1976,7 +1976,6 @@ typename DnnOp::Algorithm* try_find_any_bias_preprocess_algo(
bool
valid
=
false
;
bool
valid
=
false
;
if
(
!
layouts
[
1
].
is_empty
())
{
if
(
!
layouts
[
1
].
is_empty
())
{
valid
=
true
;
valid
=
true
;
break
;
}
}
if
(
valid
)
{
if
(
valid
)
{
found
.
emplace
(
true
);
found
.
emplace
(
true
);
...
@@ -2204,6 +2203,8 @@ TEST(TestGraph, FreeBias) {
...
@@ -2204,6 +2203,8 @@ TEST(TestGraph, FreeBias) {
param_conv_bias
.
sparse
=
opr
::
ConvBias
::
Param
::
Sparse
::
DENSE
;
param_conv_bias
.
sparse
=
opr
::
ConvBias
::
Param
::
Sparse
::
DENSE
;
auto
w1
=
mkcvar
(
"w1"
,
{
32
,
32
,
1
,
1
}),
b1
=
mkcvar
(
"b1"
,
{
1
,
32
,
1
,
1
});
auto
w1
=
mkcvar
(
"w1"
,
{
32
,
32
,
1
,
1
}),
b1
=
mkcvar
(
"b1"
,
{
1
,
32
,
1
,
1
});
auto
conv1
=
opr
::
ConvBias
::
make
(
x
,
w1
,
b1
,
param_conv_bias
);
auto
conv1
=
opr
::
ConvBias
::
make
(
x
,
w1
,
b1
,
param_conv_bias
);
auto
w2
=
mkcvar
(
"w2"
,
{
32
,
32
,
1
,
1
});
auto
conv2
=
opr
::
ConvBias
::
make
(
conv1
,
w2
,
param_conv_bias
);
Maybe
<
bool
>
wp1
;
Maybe
<
bool
>
wp1
;
conv1
.
node
()
->
owner_opr
()
->
cast_final_safe
<
opr
::
ConvBias
>
()
conv1
.
node
()
->
owner_opr
()
->
cast_final_safe
<
opr
::
ConvBias
>
()
.
setup_algo_chooser
([
&
](
const
cg
::
OperatorNodeBase
*
opr
)
{
.
setup_algo_chooser
([
&
](
const
cg
::
OperatorNodeBase
*
opr
)
{
...
@@ -2216,7 +2217,7 @@ TEST(TestGraph, FreeBias) {
...
@@ -2216,7 +2217,7 @@ TEST(TestGraph, FreeBias) {
});
});
HostTensorND
host_y
;
HostTensorND
host_y
;
auto
func
=
graph
->
compile
({
make_callback_copy
(
conv
1
,
host_y
)});
auto
func
=
graph
->
compile
({
make_callback_copy
(
conv
2
,
host_y
)});
//!flag the no need memory of var
//!flag the no need memory of var
func
->
execute
();
func
->
execute
();
//!free the no need memory of var
//!free the no need memory of var
...
...
src/opr/impl/dnn/convolution.cpp
浏览文件 @
f470df4f
...
@@ -960,11 +960,20 @@ void ConvBiasForward::scn_do_execute_preprocess() {
...
@@ -960,11 +960,20 @@ void ConvBiasForward::scn_do_execute_preprocess() {
if
(
input
().
size
()
>
3
)
{
if
(
input
().
size
()
>
3
)
{
z_layout
=
input
(
3
)
->
layout
();
z_layout
=
input
(
3
)
->
layout
();
}
}
megdnn_opr
()
->
exec_preprocess
(
if
(
input
().
size
()
>
2
)
{
input
(
0
)
->
layout
(),
input
(
1
)
->
dev_tensor
().
as_megdnn
(),
megdnn_opr
()
->
exec_preprocess
(
input
(
2
)
->
dev_tensor
().
as_megdnn
(),
z_layout
,
output
(
0
)
->
layout
(),
input
(
0
)
->
layout
(),
input
(
1
)
->
dev_tensor
().
as_megdnn
(),
preprocessed_filter
(),
input
(
2
)
->
dev_tensor
().
as_megdnn
(),
z_layout
,
intl
::
get_megdnn_workspace_from_var
(
output
().
back
()));
output
(
0
)
->
layout
(),
preprocessed_filter
(),
intl
::
get_megdnn_workspace_from_var
(
output
().
back
()));
}
else
{
megdnn
::
TensorND
bias_tensor
{
nullptr
,
bias_layout
};
megdnn_opr
()
->
exec_preprocess
(
input
(
0
)
->
layout
(),
input
(
1
)
->
dev_tensor
().
as_megdnn
(),
bias_tensor
,
z_layout
,
output
(
0
)
->
layout
(),
preprocessed_filter
(),
intl
::
get_megdnn_workspace_from_var
(
output
().
back
()));
}
//! Flag the weight and bias no use later, which can be freed when no other
//! Flag the weight and bias no use later, which can be freed when no other
//! var depend on its dev_value, host_value and shape.
//! var depend on its dev_value, host_value and shape.
auto
receiver_info_weight
=
auto
receiver_info_weight
=
...
@@ -975,7 +984,7 @@ void ConvBiasForward::scn_do_execute_preprocess() {
...
@@ -975,7 +984,7 @@ void ConvBiasForward::scn_do_execute_preprocess() {
input
(
1
)
->
add_flag
(
VarNode
::
Flag
::
MEMORY_NO_NEED
);
input
(
1
)
->
add_flag
(
VarNode
::
Flag
::
MEMORY_NO_NEED
);
}
}
//! if bias is preprocessd
//! if bias is preprocessd
if
(
input
().
size
()
>
3
)
{
if
(
input
().
size
()
>
2
)
{
auto
preprocessed_layouts
=
auto
preprocessed_layouts
=
megdnn_opr
()
->
deduce_preprocessed_filter_layout
(
megdnn_opr
()
->
deduce_preprocessed_filter_layout
(
input
(
0
)
->
layout
(),
input
(
1
)
->
layout
(),
bias_layout
,
input
(
0
)
->
layout
(),
input
(
1
)
->
layout
(),
bias_layout
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录