Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
5d637d07
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看板
提交
5d637d07
编写于
4月 20, 2021
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor(mgb): code refactor of fast run
GitOrigin-RevId: 2c4b8e06bb3c4b4cb0228ee28988c2371455b1b0
上级
f6bd4f59
变更
2
展开全部
隐藏空白更改
内联
并排
Showing
2 changed file
with
369 addition
and
364 deletion
+369
-364
src/opr/impl/search_policy/algo_chooser.cpp
src/opr/impl/search_policy/algo_chooser.cpp
+330
-328
src/opr/include/megbrain/opr/search_policy/algo_chooser.h
src/opr/include/megbrain/opr/search_policy/algo_chooser.h
+39
-36
未找到文件。
src/opr/impl/search_policy/algo_chooser.cpp
浏览文件 @
5d637d07
此差异已折叠。
点击以展开。
src/opr/include/megbrain/opr/search_policy/algo_chooser.h
浏览文件 @
5d637d07
...
...
@@ -66,7 +66,7 @@ class AlgoChooser {
public:
using
FixedTensorLayouts
=
std
::
array
<
TensorLayout
,
arity
>
;
class
ExeContext
{
class
AlgoChooserHelper
{
FixedTensorLayouts
m_layouts
;
Opr
*
m_megdnn_opr
;
std
::
string
m_param
;
...
...
@@ -76,22 +76,23 @@ public:
bool
m_allow_weight_preprocess
;
public:
ExeContext
(
const
FixedTensorLayouts
&
layouts
,
Opr
*
megdnn_opr
,
const
std
::
string
&
param_str
,
const
cg
::
OperatorNodeBase
*
mgb_opr
,
const
CompNode
&
cn
,
const
megdnn
::
param
::
ExecutionPolicy
&
execution_policy
,
bool
allow_weight_preprocess
);
AlgoChooserHelper
(
const
FixedTensorLayouts
&
layouts
,
Opr
*
megdnn_opr
,
const
std
::
string
&
param_str
,
const
cg
::
OperatorNodeBase
*
mgb_opr
,
const
CompNode
&
cn
,
const
megdnn
::
param
::
ExecutionPolicy
&
execution_policy
,
bool
allow_weight_preprocess
);
Opr
*
megdnn_opr
()
const
{
return
m_megdnn_opr
;
}
const
cg
::
OperatorNodeBase
*
mgb_opr
()
const
{
return
m_base_mgb_opr
;
}
const
TensorLayout
&
inp_layout
(
size_t
idx
)
const
{
return
m_layouts
[
idx
];
}
cg
::
ComputingGraph
*
owner_graph
()
const
{
return
m_base_mgb_opr
->
owner_graph
();
}
const
cg
::
OperatorNodeBase
*
mgb_opr
()
const
{
return
m_base_mgb_opr
;
}
const
megdnn
::
param
::
ExecutionPolicy
&
execution_policy
()
const
{
return
m_execution_policy
;
}
...
...
@@ -109,17 +110,40 @@ public:
const
FixedTensorLayouts
&
layouts
()
const
{
return
m_layouts
;
}
//! construct algo chain by heuristic
ImplExecutionPolicy
choose_by_heuristic
(
ExecutionStrategy
selected_strategy
)
const
;
const
ExecutionStrategy
&
selected_strategy
)
const
;
//! get all candidate algos, and the one choose_by_heuristic() is
//! put first
std
::
vector
<
ImplAlgo
>
get_all_candidates
()
const
;
//! construct algo chain by profiling
ImplExecutionPolicy
choose_by_profile
(
const
ExecutionStrategy
&
selected_strategy
,
bool
enable_update
)
const
;
//! get all profile algorithm from cache, return invalid if not exists
ImplAlgo
get_profile_result_from_cache
(
const
ExecutionStrategy
&
selected_strategy
)
const
;
/**
* \brief construct execution policy from cache or heuristic.
*
* \param selected_strategy select algo which matched this strategy
* \param[in,out] policy execution policy
* \param retrive_from_cache retrive algo from cache if set True, get
* from heuristic otherwise.
* \return true if contruct success and false when fail
*/
void
construct_execution_policy
(
const
ExecutionStrategy
&
selected_strategy
,
bool
retrive_from_cache
,
ImplExecutionPolicy
&
policy
)
const
;
//! get workspace size required for specific execution policy
size_t
get_workspace_size_bytes
(
const
ImplExecutionPolicy
&
policy
)
const
;
//! get all candidate algos, and the one choose_by_heuristic() is
//! put first
std
::
vector
<
ImplAlgo
>
get_all_candidates
()
const
;
/*!
* \brief profile a single algorithm
*
...
...
@@ -132,22 +156,8 @@ public:
Maybe
<
AlgoChooserProfileCache
::
ResultEntry
>
profile_single_algo
(
const
ImplExecutionPolicy
&
policy
,
double
&
timeout
)
const
;
//! get all profile algorithm from cache, return invalid if not exists
ImplAlgo
get_profile_result_from_cache
(
ExecutionStrategy
selected_strategy
)
const
;
/**
* \brief construct execution policy from cache or heuristic.
*
* \param selected_strategy select algo which matched this strategy
* \param [out] policy execution policy
* \param retrive_from_cache retrive algo from cache if set True, get
* from heuristic otherwise.
* \note When contruction fail, the policy will be cleaned.
*/
void
construct_execution_policy
(
ExecutionStrategy
selected_strategy
,
ImplExecutionPolicy
&
policy
,
bool
retrive_from_cache
=
true
)
const
;
//! profile and save to cache
void
profile
(
const
ExecutionStrategy
&
selected_strategy
)
const
;
/**
* \brief extract algo attribute from execution strategy and graph
...
...
@@ -168,14 +178,7 @@ public:
private:
//! entrance for getting algorithm according to execution strategy
static
ImplExecutionPolicy
get_policy
(
ExeContext
&
ctx
);
//! profile and save to cache
static
void
profile
(
ExeContext
&
ctx
,
ExecutionStrategy
selected_strategy
);
static
ImplExecutionPolicy
choose_by_profile
(
ExeContext
&
ctx
,
ExecutionStrategy
selected_strategy
,
bool
enable_update
=
true
);
static
ImplExecutionPolicy
get_policy
(
const
AlgoChooserHelper
&
helper
);
public:
/*!
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录