Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
273f891b
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看板
提交
273f891b
编写于
6月 10, 2020
作者:
M
Megvii Engine Team
提交者:
Xu Xinran
6月 19, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mgb/gopt): fix run-time winograd-transform and nchwxx error
GitOrigin-RevId: aca796f17defd041802e926e9f0742b02dd48de4
上级
02abc36e
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
20 addition
and
23 deletion
+20
-23
dnn/src/arm_common/conv_bias/int8/algos.cpp
dnn/src/arm_common/conv_bias/int8/algos.cpp
+2
-1
dnn/src/fallback/conv_bias/opr_impl.cpp
dnn/src/fallback/conv_bias/opr_impl.cpp
+1
-1
sdk/load-and-run/src/mgblar.cpp
sdk/load-and-run/src/mgblar.cpp
+1
-2
src/core/impl/graph/cg_impl.cpp
src/core/impl/graph/cg_impl.cpp
+0
-4
src/core/include/megbrain/graph/cg.h
src/core/include/megbrain/graph/cg.h
+3
-2
src/gopt/impl/framework.cpp
src/gopt/impl/framework.cpp
+6
-3
src/gopt/impl/weights_preprocess.cpp
src/gopt/impl/weights_preprocess.cpp
+6
-4
src/opr/impl/dnn/convolution.cpp
src/opr/impl/dnn/convolution.cpp
+1
-6
未找到文件。
dnn/src/arm_common/conv_bias/int8/algos.cpp
浏览文件 @
273f891b
...
@@ -310,7 +310,8 @@ bool ConvBiasImpl::AlgoS8CF32WinogradF23_4x4_NCHW44::usable(
...
@@ -310,7 +310,8 @@ bool ConvBiasImpl::AlgoS8CF32WinogradF23_4x4_NCHW44::usable(
(
param
.
filter_meta
.
dilation
[
0
]
==
(
param
.
filter_meta
.
dilation
[
0
]
==
param
.
filter_meta
.
dilation
[
1
]
&&
param
.
filter_meta
.
dilation
[
1
]
&&
param
.
filter_meta
.
dilation
[
0
]
==
1
)
&&
param
.
filter_meta
.
dilation
[
0
]
==
1
)
&&
param
.
compute_mode
==
param
::
ConvBias
::
ComputeMode
::
FLOAT32
&&
(
param
.
compute_mode
==
param
::
ConvBias
::
ComputeMode
::
FLOAT32
||
param
.
compute_mode
==
param
::
ConvBias
::
ComputeMode
::
DEFAULT
)
&&
param
.
src_type
.
enumv
()
==
DTypeEnum
::
QuantizedS8
&&
param
.
src_type
.
enumv
()
==
DTypeEnum
::
QuantizedS8
&&
param
.
bias_type
.
enumv
()
==
DTypeEnum
::
QuantizedS32
&&
param
.
bias_type
.
enumv
()
==
DTypeEnum
::
QuantizedS32
&&
param
.
dst_type
.
enumv
()
==
DTypeEnum
::
QuantizedS8
;
param
.
dst_type
.
enumv
()
==
DTypeEnum
::
QuantizedS8
;
...
...
dnn/src/fallback/conv_bias/opr_impl.cpp
浏览文件 @
273f891b
...
@@ -76,7 +76,7 @@ public:
...
@@ -76,7 +76,7 @@ public:
ohw_tile_size
));
ohw_tile_size
));
all_algos
.
emplace_back
(
refhold
.
back
().
get
());
all_algos
.
emplace_back
(
refhold
.
back
().
get
());
}
}
for
(
size_t
oc_tile_size
:
{
24
,
48
})
{
for
(
size_t
oc_tile_size
:
{
48
,
24
})
{
refhold
.
emplace_back
(
new
AlgoConv1x1
(
refhold
.
emplace_back
(
new
AlgoConv1x1
(
static_cast
<
MatrixMulImpl
::
AlgoBase
*>
(
algo
),
static_cast
<
MatrixMulImpl
::
AlgoBase
*>
(
algo
),
oc_tile_size
));
oc_tile_size
));
...
...
sdk/load-and-run/src/mgblar.cpp
浏览文件 @
273f891b
...
@@ -992,7 +992,6 @@ Args Args::from_argv(int argc, char **argv) {
...
@@ -992,7 +992,6 @@ Args Args::from_argv(int argc, char **argv) {
graph_opt
.
graph_opt
.
enable_nchw44_dot
();
graph_opt
.
graph_opt
.
enable_nchw44_dot
();
continue
;
continue
;
}
}
if
(
!
strcmp
(
argv
[
i
],
"--enable-fuse-conv-bias-nonlinearity"
))
{
if
(
!
strcmp
(
argv
[
i
],
"--enable-fuse-conv-bias-nonlinearity"
))
{
mgb_log_warn
(
"enable fuse-conv-bias-nonlinearity optimization"
);
mgb_log_warn
(
"enable fuse-conv-bias-nonlinearity optimization"
);
graph_opt
.
graph_opt
.
enable_fuse_conv_bias_nonlinearity
();
graph_opt
.
graph_opt
.
enable_fuse_conv_bias_nonlinearity
();
...
@@ -1202,7 +1201,7 @@ Args Args::from_argv(int argc, char **argv) {
...
@@ -1202,7 +1201,7 @@ Args Args::from_argv(int argc, char **argv) {
}
}
if
(
!
strcmp
(
argv
[
i
],
"--winograd-transform"
))
{
if
(
!
strcmp
(
argv
[
i
],
"--winograd-transform"
))
{
mgb_log_warn
(
"enable winograd transform"
);
mgb_log_warn
(
"enable winograd transform"
);
graph_opt
.
graph_opt
.
winograd_transform
=
true
;
graph_opt
.
graph_opt
.
w
eight_w
inograd_transform
=
true
;
continue
;
continue
;
}
}
...
...
src/core/impl/graph/cg_impl.cpp
浏览文件 @
273f891b
...
@@ -468,10 +468,6 @@ ComputingGraphImpl::CompileState ComputingGraphImpl::compile_prepare(
...
@@ -468,10 +468,6 @@ ComputingGraphImpl::CompileState ComputingGraphImpl::compile_prepare(
}
}
#endif
#endif
if
(
options
().
graph_opt
.
winograd_transform
)
{
options
().
graph_opt
.
winograd_transform
=
false
;
gopt
::
transform_vars_inplace_with_winograd
(
dest_vars
);
}
#if MGB_JIT
#if MGB_JIT
if
(
std
::
abs
(
options
().
graph_opt_level
)
==
0
&&
options
().
graph_opt
.
jit
)
{
if
(
std
::
abs
(
options
().
graph_opt_level
)
==
0
&&
options
().
graph_opt
.
jit
)
{
...
...
src/core/include/megbrain/graph/cg.h
浏览文件 @
273f891b
...
@@ -95,6 +95,8 @@ struct GraphCommonOptimizeOptions {
...
@@ -95,6 +95,8 @@ struct GraphCommonOptimizeOptions {
//! fuse pattern like ReLU(conv_bias(x, w, b) + z) or conv_bias(x, w, b)
//! fuse pattern like ReLU(conv_bias(x, w, b) + z) or conv_bias(x, w, b)
//! + z -> conv_bias(x, w, b, z)
//! + z -> conv_bias(x, w, b, z)
bool
fuse_conv_bias_with_z
=
false
;
bool
fuse_conv_bias_with_z
=
false
;
//! whether to enable fast-run profiled winograd opr replace
bool
weight_winograd_transform
=
false
;
enum
LayoutTransform
:
uint32_t
{
enum
LayoutTransform
:
uint32_t
{
DEFAULT
,
DEFAULT
,
NCHW4
,
///< compute using NCHW4 tensor format
NCHW4
,
///< compute using NCHW4 tensor format
...
@@ -124,6 +126,7 @@ struct GraphCommonOptimizeOptions {
...
@@ -124,6 +126,7 @@ struct GraphCommonOptimizeOptions {
SET
(
f16_io_comp
);
SET
(
f16_io_comp
);
SET
(
fuse_conv_bias_nonlinearity
);
SET
(
fuse_conv_bias_nonlinearity
);
SET
(
fuse_conv_bias_with_z
);
SET
(
fuse_conv_bias_with_z
);
SET
(
weight_winograd_transform
);
#undef SET
#undef SET
#define SET(_trans, _trans_capital) \
#define SET(_trans, _trans_capital) \
GraphCommonOptimizeOptions& enable_##_trans() { \
GraphCommonOptimizeOptions& enable_##_trans() { \
...
@@ -307,8 +310,6 @@ class ComputingGraph : public std::enable_shared_from_this<ComputingGraph>,
...
@@ -307,8 +310,6 @@ class ComputingGraph : public std::enable_shared_from_this<ComputingGraph>,
uint8_t
jit
=
0
;
uint8_t
jit
=
0
;
//! whether to enable fine-grained TensorRT opr replace
//! whether to enable fine-grained TensorRT opr replace
bool
tensorrt
=
false
;
bool
tensorrt
=
false
;
//! whether to enable fast-run profiled winograd opr replace
bool
winograd_transform
=
false
;
}
graph_opt
;
}
graph_opt
;
//! get attribute for an operator
//! get attribute for an operator
...
...
src/gopt/impl/framework.cpp
浏览文件 @
273f891b
...
@@ -10,15 +10,16 @@
...
@@ -10,15 +10,16 @@
*/
*/
#include "megbrain/gopt/framework.h"
#include "megbrain/gopt/framework.h"
#include "megbrain/gopt/inference.h"
#include "megbrain/gopt/basic_arith.h"
#include "megbrain/gopt/basic_arith.h"
#include "megbrain/gopt/misc.h"
#include "megbrain/gopt/gtrans.h"
#include "megbrain/gopt/gtrans.h"
#include "megbrain/gopt/inference.h"
#include "megbrain/gopt/misc.h"
#include "megbrain/gopt/weights_preprocess.h"
#include "megbrain/graph/cg.h"
#include "megbrain/graph/cg.h"
#include "megbrain/graph/event.h"
#include "megbrain/graph/event.h"
#include "megbrain/graph/exc_extra_info.h"
#include "megbrain/graph/exc_extra_info.h"
#include "megbrain/serialization/serializer.h"
#include "megbrain/serialization/opr_shallow_copy.h"
#include "megbrain/serialization/opr_shallow_copy.h"
#include "megbrain/serialization/serializer.h"
#include "megbrain/utils/timer.h"
#include "megbrain/utils/timer.h"
#if MGB_JIT
#if MGB_JIT
...
@@ -773,6 +774,8 @@ const GraphOptimizer& GraphOptimizer::add_passes_for_optimize_options(
...
@@ -773,6 +774,8 @@ const GraphOptimizer& GraphOptimizer::add_passes_for_optimize_options(
add_pass
<
FuseConvBiasZPass
>
();
add_pass
<
FuseConvBiasZPass
>
();
});
});
cb
(
weight_winograd_transform
,
{
add_pass
<
WinogradTransformReplacePass
>
();
});
#undef cb
#undef cb
if
(
need_param_fuse
)
{
if
(
need_param_fuse
)
{
...
...
src/gopt/impl/weights_preprocess.cpp
浏览文件 @
273f891b
...
@@ -24,6 +24,10 @@ const char* WinogradTransformReplacePass::name() const {
...
@@ -24,6 +24,10 @@ const char* WinogradTransformReplacePass::name() const {
void
WinogradTransformReplacePass
::
apply
(
OptState
&
opt
)
const
{
void
WinogradTransformReplacePass
::
apply
(
OptState
&
opt
)
const
{
auto
rewriter
=
opt
.
graph
().
make_rewriter
();
auto
rewriter
=
opt
.
graph
().
make_rewriter
();
ConstVarPropogate
cvprop
{
ConstVarType
::
IMMUTABLE_AND_PARAM
};
opt
.
graph
().
iter
([
&
cvprop
](
OperatorNodeBase
*
opr
)
{
cvprop
.
add_opr
(
opr
);
});
auto
get_algo
=
[](
const
opr
::
ConvBias
&
opr
)
->
std
::
string
{
auto
get_algo
=
[](
const
opr
::
ConvBias
&
opr
)
->
std
::
string
{
auto
&&
inputs
=
opr
.
input
();
auto
&&
inputs
=
opr
.
input
();
...
@@ -75,12 +79,10 @@ void WinogradTransformReplacePass::apply(OptState& opt) const {
...
@@ -75,12 +79,10 @@ void WinogradTransformReplacePass::apply(OptState& opt) const {
for
(
auto
i
:
inputs
)
{
for
(
auto
i
:
inputs
)
{
new_inp
.
push_back
(
rewriter
.
get_var
(
i
));
new_inp
.
push_back
(
rewriter
.
get_var
(
i
));
}
}
if
(
!
(
cvprop
.
is_midconst
(
inputs
[
1
])
||
if
(
!
inputs
[
1
]
->
contain_flag
(
cvprop
.
is_const
(
inputs
[
1
])))
{
VarNode
::
Flag
::
PERSISTENT_DEVICE_VALUE
))
{
break
;
break
;
}
}
auto
algo_name
=
get_algo
(
conv_bias_opr
);
auto
algo_name
=
get_algo
(
conv_bias_opr
);
auto
winograd_param
=
auto
winograd_param
=
megdnn
::
ConvBias
::
parse_winograd_name
(
algo_name
);
megdnn
::
ConvBias
::
parse_winograd_name
(
algo_name
);
...
...
src/opr/impl/dnn/convolution.cpp
浏览文件 @
273f891b
...
@@ -672,14 +672,9 @@ void AlgoChooser<megdnn::ConvBias>::get_origin_param_and_layouts(
...
@@ -672,14 +672,9 @@ void AlgoChooser<megdnn::ConvBias>::get_origin_param_and_layouts(
auto
format
=
static_cast
<
megdnn
::
param
::
ConvBias
::
Format
>
(
auto
format
=
static_cast
<
megdnn
::
param
::
ConvBias
::
Format
>
(
ctx
.
megdnn_opr
()
->
param
().
format
);
ctx
.
megdnn_opr
()
->
param
().
format
);
size_t
output_block_size
=
ctx
.
megdnn_opr
()
->
param
().
output_block_size
;
size_t
output_block_size
=
ctx
.
megdnn_opr
()
->
param
().
output_block_size
;
TensorLayout
origin_layout
;
megdnn
::
ConvBias
::
deduce_winograd_origin_layout_and_param
(
megdnn
::
ConvBias
::
deduce_winograd_origin_layout_and_param
(
format
,
output_block_size
,
ctx
.
layouts
()[
0
],
ctx
.
layouts
()[
1
],
format
,
output_block_size
,
ctx
.
layouts
()[
0
],
ctx
.
layouts
()[
1
],
origin_layout
,
param
);
layouts
[
1
],
param
);
for
(
size_t
i
=
0
;
i
<
ctx
.
layouts
().
size
();
i
++
)
{
layouts
[
i
]
=
ctx
.
layouts
()[
i
];
}
layouts
[
1
]
=
origin_layout
;
}
}
template
<
typename
Opr
>
template
<
typename
Opr
>
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录