Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
67e4e834
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看板
提交
67e4e834
编写于
12月 08, 2021
作者:
M
Megvii Engine Team
提交者:
XindaH
12月 10, 2021
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(lite): fix the force_output_use_user_specified_memory when out var not supported
GitOrigin-RevId: ffaf4c14164e6fff1ce6e9bc8bfe05ef1bd7673a
上级
0d37bfb0
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
41 addition
and
14 deletion
+41
-14
lite/src/mge/network_impl.cpp
lite/src/mge/network_impl.cpp
+28
-0
lite/src/mge/network_impl.h
lite/src/mge/network_impl.h
+3
-0
src/core/impl/graph/cg_impl_seq.cpp
src/core/impl/graph/cg_impl_seq.cpp
+1
-5
src/core/include/megbrain/graph/var_node.h
src/core/include/megbrain/graph/var_node.h
+4
-4
src/opr/impl/tensor_manip.cpp
src/opr/impl/tensor_manip.cpp
+2
-2
src/opr/impl/tensor_manip.sereg.h
src/opr/impl/tensor_manip.sereg.h
+1
-1
src/opr/include/megbrain/opr/tensor_manip.h
src/opr/include/megbrain/opr/tensor_manip.h
+2
-2
未找到文件。
lite/src/mge/network_impl.cpp
浏览文件 @
67e4e834
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include "megbrain/graph.h"
#include "megbrain/graph.h"
#include "megbrain/graph/cg.h"
#include "megbrain/graph/cg.h"
#include "megbrain/opr/io.h"
#include "megbrain/opr/io.h"
#include "megbrain/opr/tensor_manip.h"
#include "megbrain/tensor.h"
#include "megbrain/tensor.h"
#if MGB_OPENCL
#if MGB_OPENCL
...
@@ -340,6 +341,31 @@ void NetworkImplDft::cross_compnode_model_detect() {
...
@@ -340,6 +341,31 @@ void NetworkImplDft::cross_compnode_model_detect() {
m_nr_device_type
=
nr_used_device_type
.
size
();
m_nr_device_type
=
nr_used_device_type
.
size
();
}
}
void
NetworkImplDft
::
adapt_option_valid
()
{
auto
&&
options
=
m_load_config
.
comp_graph
->
options
();
if
(
m_user_config
->
options
.
force_output_use_user_specified_memory
)
{
for
(
auto
&&
out
:
m_load_result
.
output_var_list
)
{
auto
opr
=
out
.
node
()
->
owner_opr
();
//! all the dest operator inherit from ReadonlyFwdHelper can't
//! support force_output_use_user_specified_memory options
if
(
opr
->
try_cast_final
<
mgb
::
opr
::
Reshape
>
()
||
opr
->
try_cast_final
<
mgb
::
opr
::
Broadcast
>
()
||
opr
->
try_cast_final
<
mgb
::
opr
::
Subtensor
>
()
||
opr
->
try_cast_final
<
mgb
::
opr
::
AxisAddRemove
>
()
||
opr
->
try_cast_final
<
mgb
::
opr
::
Dimshuffle
>
())
{
m_user_config
->
options
.
force_output_use_user_specified_memory
=
false
;
options
.
force_output_use_user_specified_memory
=
false
;
LITE_WARN
(
"detect the unsupported dest operator %s when config "
"force_output_use_user_specified_memory, set "
"force_output_use_user_specified_memory to false
\n
"
,
opr
->
cname
());
break
;
}
}
}
}
void
NetworkImplDft
::
load_model
(
void
NetworkImplDft
::
load_model
(
std
::
shared_ptr
<
void
>
model_mem
,
size_t
size
,
std
::
shared_ptr
<
void
>
model_mem
,
size_t
size
,
std
::
unordered_map
<
std
::
string
,
LiteAny
>
separate_config_map
)
{
std
::
unordered_map
<
std
::
string
,
LiteAny
>
separate_config_map
)
{
...
@@ -378,6 +404,8 @@ void NetworkImplDft::load_model(
...
@@ -378,6 +404,8 @@ void NetworkImplDft::load_model(
m_load_result
=
m_loader
->
load
(
m_load_config
,
true
);
m_load_result
=
m_loader
->
load
(
m_load_config
,
true
);
adapt_option_valid
();
cross_compnode_model_detect
();
cross_compnode_model_detect
();
//! update the IO of the network
//! update the IO of the network
...
...
lite/src/mge/network_impl.h
浏览文件 @
67e4e834
...
@@ -214,6 +214,9 @@ private:
...
@@ -214,6 +214,9 @@ private:
//! optimized output tensor copy
//! optimized output tensor copy
void
output_tensor_copy_optimize
(
Var
var
,
std
::
shared_ptr
<
Tensor
>
tensor
);
void
output_tensor_copy_optimize
(
Var
var
,
std
::
shared_ptr
<
Tensor
>
tensor
);
//! adapt option valid, it should call after update_io
void
adapt_option_valid
();
private:
private:
bool
m_async
=
false
;
bool
m_async
=
false
;
bool
m_is_cpu_inplace_mode
=
false
;
bool
m_is_cpu_inplace_mode
=
false
;
...
...
src/core/impl/graph/cg_impl_seq.cpp
浏览文件 @
67e4e834
...
@@ -250,14 +250,10 @@ std::unique_ptr<CompNodeSeqRecorder> ComputingGraphImpl::ComputingSequence::
...
@@ -250,14 +250,10 @@ std::unique_ptr<CompNodeSeqRecorder> ComputingGraphImpl::ComputingSequence::
"graph."
);
"graph."
);
return
{};
return
{};
}
}
auto
is_graph_dest_varnode
=
[
&
](
VarNode
*
var
)
{
return
ComputingGraphImpl
::
downcast
(
owner_graph
())
->
var_receiver
(
var
).
size
()
==
0
;
};
for
(
auto
i
:
*
m_opr_seq
)
{
for
(
auto
i
:
*
m_opr_seq
)
{
for
(
auto
j
:
i
->
output
())
{
for
(
auto
j
:
i
->
output
())
{
if
(
!
is_static_var_storage
(
j
)
&&
!
is_graph_dest_varnode
(
j
))
{
if
(
!
is_static_var_storage
(
j
)
&&
!
j
->
is_graph_dest_varnode
(
))
{
mgb_log_error
(
mgb_log_error
(
"can not enable CompNodeSeqRecorder because var "
"can not enable CompNodeSeqRecorder because var "
"storage not static: %s"
,
"storage not static: %s"
,
...
...
src/core/include/megbrain/graph/var_node.h
浏览文件 @
67e4e834
...
@@ -504,6 +504,10 @@ public:
...
@@ -504,6 +504,10 @@ public:
*/
*/
MGE_WIN_DECLSPEC_FUC
bool
capable_value_infer
();
MGE_WIN_DECLSPEC_FUC
bool
capable_value_infer
();
//! whether the var is graph output, if it is output, the Flag of
//! NO_SYS_MEM_ALLOC can be modified.
MGE_WIN_DECLSPEC_FUC
bool
is_graph_dest_varnode
();
private:
private:
//! whether its memory should be allocated by mgb system during graph
//! whether its memory should be allocated by mgb system during graph
//! execution; initialized in VarNodeMemManager::reset_opr_seq()
//! execution; initialized in VarNodeMemManager::reset_opr_seq()
...
@@ -552,10 +556,6 @@ private:
...
@@ -552,10 +556,6 @@ private:
MGE_WIN_DECLSPEC_FUC
void
modify_flag
(
Flag
delta
,
Flag
new_flag
);
MGE_WIN_DECLSPEC_FUC
void
modify_flag
(
Flag
delta
,
Flag
new_flag
);
//! whether the var is graph output, if it is output, the Flag of
//! NO_SYS_MEM_ALLOC can be modified.
bool
is_graph_dest_varnode
();
MGE_WIN_DECLSPEC_FUC
void
assign_dev_tensor_from_tensor
(
MGE_WIN_DECLSPEC_FUC
void
assign_dev_tensor_from_tensor
(
const
DeviceTensorND
&
value
);
const
DeviceTensorND
&
value
);
...
...
src/opr/impl/tensor_manip.cpp
浏览文件 @
67e4e834
...
@@ -919,7 +919,7 @@ Split::Options Split::Options::make_callback(
...
@@ -919,7 +919,7 @@ Split::Options Split::Options::make_callback(
int
axis
,
size_t
nr_part
,
callback_t
callback
)
{
int
axis
,
size_t
nr_part
,
callback_t
callback
)
{
mgb_assert
(
nr_part
);
mgb_assert
(
nr_part
);
Options
rst
;
Options
rst
;
rst
.
method
=
Method
::
CALLBACK
;
rst
.
method
=
Method
::
CALL
_
BACK
;
rst
.
axis
=
axis
;
rst
.
axis
=
axis
;
rst
.
callback
=
callback
;
rst
.
callback
=
callback
;
rst
.
nr_part
=
nr_part
;
rst
.
nr_part
=
nr_part
;
...
@@ -955,7 +955,7 @@ Split::Split(VarNode* inp, const Options& opt, const OperatorNodeConfig& config)
...
@@ -955,7 +955,7 @@ Split::Split(VarNode* inp, const Options& opt, const OperatorNodeConfig& config)
// disable dedup
// disable dedup
add_equivalence_component
<
ScalarHash
<
void
*>>
(
this
);
add_equivalence_component
<
ScalarHash
<
void
*>>
(
this
);
mgb_assert
(
m_opt
.
method
==
Options
::
Method
::
CALLBACK
);
mgb_assert
(
m_opt
.
method
==
Options
::
Method
::
CALL
_
BACK
);
mgb_assert
(
m_opt
.
nr_part
);
mgb_assert
(
m_opt
.
nr_part
);
}
}
...
...
src/opr/impl/tensor_manip.sereg.h
浏览文件 @
67e4e834
...
@@ -172,7 +172,7 @@ cg::OperatorNodeBase* opr_shallow_copy_split(
...
@@ -172,7 +172,7 @@ cg::OperatorNodeBase* opr_shallow_copy_split(
auto
option
=
opr
.
options
();
auto
option
=
opr
.
options
();
using
Meth
=
Split
::
Options
::
Method
;
using
Meth
=
Split
::
Options
::
Method
;
switch
(
option
.
method
)
{
switch
(
option
.
method
)
{
case
Meth
::
CALLBACK
:
case
Meth
::
CALL
_
BACK
:
mgb_assert
(
inputs
.
size
()
==
1
);
mgb_assert
(
inputs
.
size
()
==
1
);
break
;
break
;
case
Meth
::
SPECIFY
:
case
Meth
::
SPECIFY
:
...
...
src/opr/include/megbrain/opr/tensor_manip.h
浏览文件 @
67e4e834
...
@@ -409,7 +409,7 @@ public:
...
@@ -409,7 +409,7 @@ public:
struct
Options
{
struct
Options
{
enum
class
Method
{
enum
class
Method
{
SPECIFY
,
//!< specify output sizes
SPECIFY
,
//!< specify output sizes
CALLBACK
//!< output sizes obtained from callback
CALL
_
BACK
//!< output sizes obtained from callback
};
};
Method
method
;
Method
method
;
size_t
nr_part
=
0
;
size_t
nr_part
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录