Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
MegEngine 天元
MegEngine
提交
2afceb41
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看板
提交
2afceb41
编写于
7月 30, 2020
作者:
M
Megvii Engine Team
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(mgb/atlas): use dyn output alloc if enable dynamic batchsize
GitOrigin-RevId: 45a6c6ad518de9172101fef4003988b24e86b1a3
上级
6bcc6fae
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
19 addition
and
6 deletion
+19
-6
src/core/impl/graph/var_node.cpp
src/core/impl/graph/var_node.cpp
+2
-2
src/core/impl/graph/var_node_mem_mgr.cpp
src/core/impl/graph/var_node_mem_mgr.cpp
+7
-2
src/core/impl/graph/var_node_mem_mgr.h
src/core/impl/graph/var_node_mem_mgr.h
+7
-1
src/core/include/megbrain/graph/var_node.h
src/core/include/megbrain/graph/var_node.h
+3
-1
未找到文件。
src/core/impl/graph/var_node.cpp
浏览文件 @
2afceb41
...
...
@@ -307,7 +307,7 @@ VarNode& VarNode::shape(const TensorShape &shape) {
return
*
this
;
}
VarNode
&
VarNode
::
shape_alloc
(
const
TensorShape
&
shape
)
{
VarNode
&
VarNode
::
shape_alloc
(
const
TensorShape
&
shape
,
size_t
size_req
)
{
mgb_assert
(
shape
.
ndim
,
"got empty shape in shape_alloc: "
"var=%s owner_opr=%s{%s}"
,
cname
(),
owner_opr
()
->
cname
(),
owner_opr
()
->
dyn_typeinfo
()
->
name
);
...
...
@@ -316,7 +316,7 @@ VarNode& VarNode::shape_alloc(const TensorShape &shape) {
" NO_SYS_MEM_ALLOC flag; actual var: %s"
,
cg
::
dump_var_info
({
this
}).
c_str
());
ComputingGraphImpl
::
downcast
(
owner_graph
())
->
var_node_mem_manager
().
var_alloc_with_shape
(
this
,
shape
);
->
var_node_mem_manager
().
var_alloc_with_shape
(
this
,
shape
,
size_req
);
return
*
this
;
}
...
...
src/core/impl/graph/var_node_mem_mgr.cpp
浏览文件 @
2afceb41
...
...
@@ -1239,13 +1239,18 @@ void VarNodeMemManager::make_dev_tensor_from_mem_plan_single(
}
void
VarNodeMemManager
::
var_alloc_with_shape
(
VarNode
*
var
,
const
TensorShape
&
shape
)
{
const
TensorShape
&
shape
,
size_t
size_req
)
{
mgb_assert
(
var
->
format
().
is_default
(),
"dynamic shape is currently only supported for var with "
"default format; got %s"
,
var
->
format
().
to_string
().
c_str
());
var
->
shape
(
shape
);
auto
size_req
=
var
->
dtype
().
size
(
shape
.
total_nr_elems
());
if
(
size_req
!=
0
)
{
mgb_assert
(
var
->
dtype
().
size
(
shape
.
total_nr_elems
())
<=
size_req
);
}
else
{
size_req
=
var
->
dtype
().
size
(
shape
.
total_nr_elems
());
}
auto
&&
mplan
=
var
->
m_mem_plan
;
if
(
!
mplan
.
valid
()
||
mplan
.
chunk
().
owner_var
!=
var
)
...
...
src/core/impl/graph/var_node_mem_mgr.h
浏览文件 @
2afceb41
...
...
@@ -294,7 +294,13 @@ class VarNodeMemManager {
void
add_layout_constraint_level
(
VarNode
*
dest
,
LayoutConstraintLevel
level
);
void
var_alloc_with_shape
(
VarNode
*
var
,
const
TensorShape
&
shape
);
/**
* \brief alloc var memory with shape.
*
* Alloc memory of size_seq if size_req != 0.
*/
void
var_alloc_with_shape
(
VarNode
*
var
,
const
TensorShape
&
shape
,
size_t
size_req
=
0
);
/*!
* \brief initialize mem plan for a single var
...
...
src/core/include/megbrain/graph/var_node.h
浏览文件 @
2afceb41
...
...
@@ -462,8 +462,10 @@ class VarNode final: public GraphNodeBase {
* this var must have NO_SYS_MEM_ALLOC flag; if shape does not increase
* and original tensor storage is valid, it is guaranteed that old data
* would be retained.
*
* \warning Alloc size_req memory if size_req != 0.
*/
VarNode
&
shape_alloc
(
const
TensorShape
&
shape
);
VarNode
&
shape_alloc
(
const
TensorShape
&
shape
,
size_t
size_req
=
0
);
/*!
* \brief directly reset device tensor from another var
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录