Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
94d23921
Mace
项目概览
Xiaomi
/
Mace
通知
107
Star
40
Fork
27
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Mace
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
94d23921
编写于
3月 09, 2018
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GPU memory reusing support multiple outputs.
上级
4cf4120c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
24 addition
and
24 deletion
+24
-24
mace/core/mace.cc
mace/core/mace.cc
+7
-7
mace/core/workspace.cc
mace/core/workspace.cc
+14
-13
mace/public/mace.h
mace/public/mace.h
+3
-4
未找到文件。
mace/core/mace.cc
浏览文件 @
94d23921
...
...
@@ -153,7 +153,9 @@ void OperatorDef::CopyFrom(const OperatorDef &from) {
output_type_
.
resize
(
from_data_type
.
size
());
std
::
copy
(
from_data_type
.
begin
(),
from_data_type
.
end
(),
output_type_
.
begin
());
mem_id_
=
from
.
mem_id
();
auto
mem_ids
=
from
.
mem_id
();
mem_id_
.
resize
(
mem_ids
.
size
());
std
::
copy
(
mem_ids
.
begin
(),
mem_ids
.
end
(),
mem_id_
.
begin
());
// nnlib
node_id_
=
from
.
node_id
();
...
...
@@ -186,13 +188,11 @@ void OperatorDef::set_type(const std::string &type_) {
}
bool
OperatorDef
::
has_type
()
const
{
return
(
has_bits_
&
0x00000002u
)
!=
0
;
}
void
OperatorDef
::
set_has_type
()
{
has_bits_
|=
0x00000002u
;
}
int
OperatorDef
::
mem_id
()
const
{
return
mem_id_
;
}
void
OperatorDef
::
set_mem_id
(
const
int
mem_id
)
{
set_has_mem_id
(
);
mem_id_
=
mem_id
;
const
std
::
vector
<
int
>
&
OperatorDef
::
mem_id
()
const
{
return
mem_id_
;
}
void
OperatorDef
::
set_mem_id
(
const
std
::
vector
<
int
>
&
value
)
{
mem_id_
.
resize
(
value
.
size
()
);
std
::
copy
(
value
.
begin
(),
value
.
end
(),
mem_id_
.
begin
())
;
}
bool
OperatorDef
::
has_mem_id
()
const
{
return
(
has_bits_
&
0x00000004u
)
!=
0
;
}
void
OperatorDef
::
set_has_mem_id
()
{
has_bits_
|=
0x00000004u
;
}
uint32_t
OperatorDef
::
node_id
()
const
{
return
node_id_
;
}
void
OperatorDef
::
set_node_id
(
uint32_t
node_id
)
{
node_id_
=
node_id
;
}
uint32_t
OperatorDef
::
op_id
()
const
{
return
op_id_
;
}
...
...
mace/core/workspace.cc
浏览文件 @
94d23921
...
...
@@ -116,7 +116,7 @@ void Workspace::CreateImageOutputTensor(const NetDef &net_def) {
// As DSP may have different data output type for each op,
// we stick to the same concept.
for
(
auto
&
op
:
net_def
.
op
())
{
if
(
op
.
has_mem_id
())
{
if
(
!
op
.
mem_id
().
empty
())
{
const
DataType
op_dtype
=
static_cast
<
DataType
>
(
ArgumentHelper
::
GetSingleArgument
<
OperatorDef
,
int
>
(
op
,
"T"
,
static_cast
<
int
>
(
DT_FLOAT
)));
...
...
@@ -135,18 +135,19 @@ void Workspace::CreateImageOutputTensor(const NetDef &net_def) {
}
VLOG
(
3
)
<<
"Preallocate image to tensors"
;
for
(
auto
&
op
:
net_def
.
op
())
{
if
(
op
.
has_mem_id
())
{
std
::
unique_ptr
<
Tensor
>
tensor
(
new
Tensor
(
preallocated_allocator_
.
GetBuffer
(
op
.
mem_id
()),
dtype
));
tensor
->
SetSourceOpName
(
op
.
name
());
VLOG
(
3
)
<<
"Tensor: "
<<
op
.
name
()
<<
"("
<<
op
.
type
()
<<
")"
<<
"; Mem: "
<<
op
.
mem_id
()
<<
"; Image shape: "
<<
dynamic_cast
<
Image
*>
(
tensor
->
UnderlyingBuffer
())
->
image_shape
()[
0
]
<<
", "
<<
dynamic_cast
<
Image
*>
(
tensor
->
UnderlyingBuffer
())
->
image_shape
()[
1
];
tensor_map_
[
op
.
output
(
0
)]
=
std
::
move
(
tensor
);
if
(
!
op
.
mem_id
().
empty
())
{
auto
mem_ids
=
op
.
mem_id
();
for
(
auto
mem_id
:
mem_ids
)
{
std
::
unique_ptr
<
Tensor
>
tensor
(
new
Tensor
(
preallocated_allocator_
.
GetBuffer
(
mem_id
),
dtype
));
tensor
->
SetSourceOpName
(
op
.
name
());
VLOG
(
3
)
<<
"Tensor: "
<<
op
.
name
()
<<
"("
<<
op
.
type
()
<<
")"
<<
"; Mem: "
<<
mem_id
<<
"; Image shape: "
<<
dynamic_cast
<
Image
*>
(
tensor
->
UnderlyingBuffer
())
->
image_shape
()[
0
]
<<
", "
<<
dynamic_cast
<
Image
*>
(
tensor
->
UnderlyingBuffer
())
->
image_shape
()[
1
];
tensor_map_
[
op
.
output
(
0
)]
=
std
::
move
(
tensor
);
}
}
}
}
...
...
mace/public/mace.h
浏览文件 @
94d23921
...
...
@@ -174,9 +174,8 @@ class OperatorDef {
const
std
::
string
&
type
()
const
;
void
set_type
(
const
std
::
string
&
type_
);
bool
has_type
()
const
;
int
mem_id
()
const
;
void
set_mem_id
(
const
int
mem_id
);
bool
has_mem_id
()
const
;
const
std
::
vector
<
int
>
&
mem_id
()
const
;
void
set_mem_id
(
const
std
::
vector
<
int
>
&
value
);
uint32_t
node_id
()
const
;
void
set_node_id
(
uint32_t
node_id
);
uint32_t
op_id
()
const
;
...
...
@@ -220,7 +219,7 @@ class OperatorDef {
std
::
vector
<
OutputShape
>
output_shape_
;
std
::
vector
<
DataType
>
output_type_
;
int
mem_id_
;
std
::
vector
<
int
>
mem_id_
;
// nnlib
uint32_t
node_id_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录