Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
91539064
Mace
项目概览
Xiaomi
/
Mace
通知
106
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
91539064
编写于
3月 26, 2019
作者:
叶
叶剑武
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'memory-leak' into 'master'
BUG: fix memory leak in SerialNet(96 bytes) See merge request !1026
上级
1852e328
5371f986
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
21 addition
and
17 deletion
+21
-17
.gitlab-ci.yml
.gitlab-ci.yml
+1
-1
mace/core/device.cc
mace/core/device.cc
+5
-4
mace/core/net.cc
mace/core/net.cc
+9
-7
mace/core/net.h
mace/core/net.h
+1
-1
mace/core/runtime/cpu/cpu_runtime.h
mace/core/runtime/cpu/cpu_runtime.h
+2
-2
tools/device.py
tools/device.py
+1
-0
tools/sh_commands.py
tools/sh_commands.py
+2
-2
未找到文件。
.gitlab-ci.yml
浏览文件 @
91539064
...
...
@@ -144,7 +144,7 @@ model_tests:
-
CONF_FILE=mace-models/mobilenet-v2/mobilenet-v2-host.yml
-
>
python tools/converter.py convert --config=${CONF_FILE} --target_socs=$TARGET_SOCS --model_graph_format=file --model_data_format=file || exit 1;
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --round=1 --validate --model_graph_format=file --model_data_format=file || exit 1;
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --round=1 --validate --model_graph_format=file --model_data_format=file
--address_sanitizer
|| exit 1;
python tools/converter.py run --config=${CONF_FILE} --target_socs=$TARGET_SOCS --example --round=1 --validate --model_graph_format=file --model_data_format=file || exit 1;
python tools/converter.py benchmark --config=${CONF_FILE} --target_socs=$TARGET_SOCS --round=5 --model_graph_format=file --model_data_format=file || exit 1;
python tools/converter.py convert --config=${CONF_FILE} --target_socs=$TARGET_SOCS --model_graph_format=code --model_data_format=file || exit 1;
...
...
mace/core/device.cc
浏览文件 @
91539064
...
...
@@ -15,16 +15,17 @@
#include "mace/core/device.h"
#include "mace/core/buffer.h"
#include "mace/utils/memory.h"
namespace
mace
{
CPUDevice
::
CPUDevice
(
const
int
num_threads
,
const
CPUAffinityPolicy
policy
,
const
bool
use_gemmlowp
)
:
cpu_runtime_
(
new
CPURuntime
(
num_threads
,
policy
,
use_gemmlowp
)),
scratch_buffer_
(
new
ScratchBuffer
(
GetCPUAllocator
()))
{}
:
cpu_runtime_
(
make_unique
<
CPURuntime
>
(
num_threads
,
policy
,
use_gemmlowp
)),
scratch_buffer_
(
make_unique
<
ScratchBuffer
>
(
GetCPUAllocator
()))
{}
CPUDevice
::~
CPUDevice
()
=
default
;
...
...
mace/core/net.cc
浏览文件 @
91539064
...
...
@@ -28,6 +28,7 @@
#include "mace/utils/logging.h"
#include "mace/utils/macros.h"
#include "mace/utils/math.h"
#include "mace/utils/memory.h"
#include "mace/utils/timer.h"
#ifdef MACE_ENABLE_OPENCL
...
...
@@ -77,7 +78,7 @@ std::unique_ptr<Operation> SerialNet::CreateOperation(
// Create the Operation
DeviceType
target_device_type
=
target_device_
->
device_type
();
DeviceType
device_type
=
DeviceType
::
CPU
;
construct_context
->
set_device
(
cpu_device_
);
construct_context
->
set_device
(
cpu_device_
.
get
()
);
construct_context
->
set_operator_def
(
op_def
);
construct_context
->
set_output_mem_type
(
MemoryType
::
CPU_BUFFER
);
// Get available devices
...
...
@@ -129,9 +130,10 @@ SerialNet::SerialNet(const OpRegistryBase *op_registry,
ws_
(
ws
),
target_device_
(
target_device
),
cpu_device_
(
new
CPUDevice
(
target_device
->
cpu_runtime
()
->
num_threads
(),
target_device
->
cpu_runtime
()
->
policy
(),
target_device
->
cpu_runtime
()
->
use_gemmlowp
()))
{
make_unique
<
CPUDevice
>
(
target_device
->
cpu_runtime
()
->
num_threads
(),
target_device
->
cpu_runtime
()
->
policy
(),
target_device
->
cpu_runtime
()
->
use_gemmlowp
()))
{
MACE_LATENCY_LOGGER
(
1
,
"Constructing SerialNet"
);
// output tensor : related information
std
::
unordered_map
<
std
::
string
,
InternalOutputInfo
>
output_map
;
...
...
@@ -380,7 +382,7 @@ MaceStatus SerialNet::Init() {
if
(
device_type
==
target_device_
->
device_type
())
{
init_context
.
set_device
(
target_device_
);
}
else
{
init_context
.
set_device
(
cpu_device_
);
init_context
.
set_device
(
cpu_device_
.
get
()
);
}
// Initialize the operation
MACE_RETURN_IF_ERROR
(
op
->
Init
(
&
init_context
));
...
...
@@ -391,7 +393,7 @@ MaceStatus SerialNet::Init() {
MaceStatus
SerialNet
::
Run
(
RunMetadata
*
run_metadata
)
{
MACE_MEMORY_LOGGING_GUARD
();
MACE_LATENCY_LOGGER
(
1
,
"Running net"
);
OpContext
context
(
ws_
,
cpu_device_
);
OpContext
context
(
ws_
,
cpu_device_
.
get
()
);
for
(
auto
iter
=
operators_
.
begin
();
iter
!=
operators_
.
end
();
++
iter
)
{
auto
&
op
=
*
iter
;
DeviceType
device_type
=
op
->
device_type
();
...
...
@@ -404,7 +406,7 @@ MaceStatus SerialNet::Run(RunMetadata *run_metadata) {
if
(
device_type
==
target_device_
->
device_type
())
{
context
.
set_device
(
target_device_
);
}
else
{
context
.
set_device
(
cpu_device_
);
context
.
set_device
(
cpu_device_
.
get
()
);
}
CallStats
call_stats
;
...
...
mace/core/net.h
浏览文件 @
91539064
...
...
@@ -66,7 +66,7 @@ class SerialNet : public NetBase {
Workspace
*
ws_
;
Device
*
target_device_
;
// CPU is base device.
Device
*
cpu_device_
;
std
::
unique_ptr
<
Device
>
cpu_device_
;
std
::
vector
<
std
::
unique_ptr
<
Operation
>
>
operators_
;
MACE_DISABLE_COPY_AND_ASSIGN
(
SerialNet
);
...
...
mace/core/runtime/cpu/cpu_runtime.h
浏览文件 @
91539064
...
...
@@ -52,13 +52,13 @@ class CPURuntime {
#ifdef MACE_ENABLE_QUANTIZE
~
CPURuntime
()
{
if
(
!
gemm_context_
)
{
if
(
gemm_context_
!=
nullptr
)
{
delete
static_cast
<
gemmlowp
::
GemmContext
*>
(
gemm_context_
);
}
}
gemmlowp
::
GemmContext
*
GetGemmlowpContext
()
{
if
(
!
gemm_context_
)
{
if
(
gemm_context_
==
nullptr
)
{
gemm_context_
=
new
gemmlowp
::
GemmContext
();
}
return
static_cast
<
gemmlowp
::
GemmContext
*>
(
gemm_context_
);
...
...
tools/device.py
浏览文件 @
91539064
...
...
@@ -208,6 +208,7 @@ class DeviceWrapper:
p
=
subprocess
.
Popen
(
[
"env"
,
"ASAN_OPTIONS=detect_leaks=1"
,
"LD_LIBRARY_PATH=%s"
%
libmace_dynamic_lib_path
,
"MACE_CPP_MIN_VLOG_LEVEL=%s"
%
vlog_level
,
"MACE_RUNTIME_FAILURE_RATIO=%f"
%
runtime_failure_ratio
,
...
...
tools/sh_commands.py
浏览文件 @
91539064
...
...
@@ -307,8 +307,8 @@ def bazel_build(target,
bazel_args
+=
(
"--config"
,
"asan"
)
else
:
bazel_args
+=
(
"--config"
,
"optimization"
)
if
symbol_hidden
:
bazel_args
+=
(
"--config"
,
"symbol_hidden"
)
if
symbol_hidden
:
bazel_args
+=
(
"--config"
,
"symbol_hidden"
)
if
extra_args
:
bazel_args
+=
(
extra_args
,)
six
.
print_
(
bazel_args
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录