Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
毕竟曾有刹那
Mace
提交
d7658a6e
Mace
项目概览
毕竟曾有刹那
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
0
Fork
0
代码
文件
提交
分支
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,发现更多精彩内容 >>
提交
d7658a6e
编写于
4月 03, 2019
作者:
L
Liangliang He
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix nullptr in mace_run when build with code mode
上级
cabe5cbe
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
33 addition
and
11 deletion
+33
-11
docs/development/how_to_debug.rst
docs/development/how_to_debug.rst
+1
-1
mace/benchmark/benchmark_model.cc
mace/benchmark/benchmark_model.cc
+5
-2
mace/examples/cli/example.cc
mace/examples/cli/example.cc
+5
-2
mace/port/file_system.h
mace/port/file_system.h
+15
-2
mace/port/posix/file_system.cc
mace/port/posix/file_system.cc
+2
-2
mace/tools/validation/mace_run.cc
mace/tools/validation/mace_run.cc
+5
-2
未找到文件。
docs/development/how_to_debug.rst
浏览文件 @
d7658a6e
...
@@ -90,7 +90,7 @@ For android, you can use `ndk-stack tools <https://developer.android.com/ndk/gui
...
@@ -90,7 +90,7 @@ For android, you can use `ndk-stack tools <https://developer.android.com/ndk/gui
.. code:: sh
.. code:: sh
adb logcat | $
NDK
/ndk-stack -sym /path/to/local/binary/directory/
adb logcat | $
ANDROID_NDK_HOME
/ndk-stack -sym /path/to/local/binary/directory/
Debug memory usage
Debug memory usage
...
...
mace/benchmark/benchmark_model.cc
浏览文件 @
d7658a6e
...
@@ -25,6 +25,7 @@
...
@@ -25,6 +25,7 @@
#include "mace/port/file_system.h"
#include "mace/port/file_system.h"
#include "mace/public/mace.h"
#include "mace/public/mace.h"
#include "mace/utils/logging.h"
#include "mace/utils/logging.h"
#include "mace/utils/memory.h"
#include "mace/utils/math.h"
#include "mace/utils/math.h"
#include "mace/benchmark/statistics.h"
#include "mace/benchmark/statistics.h"
#ifdef MODEL_GRAPH_FORMAT_CODE
#ifdef MODEL_GRAPH_FORMAT_CODE
...
@@ -284,7 +285,8 @@ int Main(int argc, char **argv) {
...
@@ -284,7 +285,8 @@ int Main(int argc, char **argv) {
std
::
shared_ptr
<
mace
::
MaceEngine
>
engine
;
std
::
shared_ptr
<
mace
::
MaceEngine
>
engine
;
MaceStatus
create_engine_status
;
MaceStatus
create_engine_status
;
// Create Engine
// Create Engine
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_graph_data
;
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_graph_data
=
make_unique
<
mace
::
port
::
ReadOnlyBufferMemoryRegion
>
();
if
(
FLAGS_model_file
!=
""
)
{
if
(
FLAGS_model_file
!=
""
)
{
auto
fs
=
GetFileSystem
();
auto
fs
=
GetFileSystem
();
auto
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
FLAGS_model_file
.
c_str
(),
auto
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
FLAGS_model_file
.
c_str
(),
...
@@ -294,7 +296,8 @@ int Main(int argc, char **argv) {
...
@@ -294,7 +296,8 @@ int Main(int argc, char **argv) {
}
}
}
}
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_weights_data
;
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_weights_data
=
make_unique
<
mace
::
port
::
ReadOnlyBufferMemoryRegion
>
();
if
(
FLAGS_model_data_file
!=
""
)
{
if
(
FLAGS_model_data_file
!=
""
)
{
auto
fs
=
GetFileSystem
();
auto
fs
=
GetFileSystem
();
auto
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
auto
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
...
...
mace/examples/cli/example.cc
浏览文件 @
d7658a6e
...
@@ -31,6 +31,7 @@
...
@@ -31,6 +31,7 @@
#include "mace/port/file_system.h"
#include "mace/port/file_system.h"
#include "mace/public/mace.h"
#include "mace/public/mace.h"
#include "mace/utils/logging.h"
#include "mace/utils/logging.h"
#include "mace/utils/memory.h"
#include "mace/utils/string_util.h"
#include "mace/utils/string_util.h"
// if convert model to code.
// if convert model to code.
#ifdef MODEL_GRAPH_FORMAT_CODE
#ifdef MODEL_GRAPH_FORMAT_CODE
...
@@ -201,7 +202,8 @@ bool RunModel(const std::vector<std::string> &input_names,
...
@@ -201,7 +202,8 @@ bool RunModel(const std::vector<std::string> &input_names,
std
::
shared_ptr
<
mace
::
MaceEngine
>
engine
;
std
::
shared_ptr
<
mace
::
MaceEngine
>
engine
;
MaceStatus
create_engine_status
;
MaceStatus
create_engine_status
;
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_graph_data
;
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_graph_data
=
make_unique
<
mace
::
port
::
ReadOnlyBufferMemoryRegion
>
();
if
(
FLAGS_model_file
!=
""
)
{
if
(
FLAGS_model_file
!=
""
)
{
auto
fs
=
GetFileSystem
();
auto
fs
=
GetFileSystem
();
auto
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
FLAGS_model_file
.
c_str
(),
auto
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
FLAGS_model_file
.
c_str
(),
...
@@ -211,7 +213,8 @@ bool RunModel(const std::vector<std::string> &input_names,
...
@@ -211,7 +213,8 @@ bool RunModel(const std::vector<std::string> &input_names,
}
}
}
}
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_weights_data
;
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_weights_data
=
make_unique
<
mace
::
port
::
ReadOnlyBufferMemoryRegion
>
();
if
(
FLAGS_model_data_file
!=
""
)
{
if
(
FLAGS_model_data_file
!=
""
)
{
auto
fs
=
GetFileSystem
();
auto
fs
=
GetFileSystem
();
auto
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
auto
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
...
...
mace/port/file_system.h
浏览文件 @
d7658a6e
...
@@ -27,8 +27,21 @@ class ReadOnlyMemoryRegion {
...
@@ -27,8 +27,21 @@ class ReadOnlyMemoryRegion {
public:
public:
ReadOnlyMemoryRegion
()
=
default
;
ReadOnlyMemoryRegion
()
=
default
;
virtual
~
ReadOnlyMemoryRegion
()
=
default
;
virtual
~
ReadOnlyMemoryRegion
()
=
default
;
virtual
const
void
*
data
()
=
0
;
virtual
const
void
*
data
()
const
=
0
;
virtual
uint64_t
length
()
=
0
;
virtual
uint64_t
length
()
const
=
0
;
};
class
ReadOnlyBufferMemoryRegion
:
public
ReadOnlyMemoryRegion
{
public:
ReadOnlyBufferMemoryRegion
()
:
data_
(
nullptr
),
length_
(
0
)
{}
ReadOnlyBufferMemoryRegion
(
const
void
*
data
,
uint64_t
length
)
:
data_
(
data
),
length_
(
length
)
{}
const
void
*
data
()
const
override
{
return
data_
;
}
uint64_t
length
()
const
override
{
return
length_
;
}
private:
const
void
*
data_
;
uint64_t
length_
;
};
};
class
FileSystem
{
class
FileSystem
{
...
...
mace/port/posix/file_system.cc
浏览文件 @
d7658a6e
...
@@ -38,8 +38,8 @@ class PosixReadOnlyMemoryRegion : public ReadOnlyMemoryRegion {
...
@@ -38,8 +38,8 @@ class PosixReadOnlyMemoryRegion : public ReadOnlyMemoryRegion {
munmap
(
const_cast
<
void
*>
(
addr_
),
length_
);
munmap
(
const_cast
<
void
*>
(
addr_
),
length_
);
}
}
};
};
const
void
*
data
()
override
{
return
addr_
;
};
const
void
*
data
()
const
override
{
return
addr_
;
};
uint64_t
length
()
override
{
return
length_
;
};
uint64_t
length
()
const
override
{
return
length_
;
};
private:
private:
const
void
*
addr_
;
const
void
*
addr_
;
...
...
mace/tools/validation/mace_run.cc
浏览文件 @
d7658a6e
...
@@ -37,6 +37,7 @@
...
@@ -37,6 +37,7 @@
#include "mace/port/env.h"
#include "mace/port/env.h"
#include "mace/port/file_system.h"
#include "mace/port/file_system.h"
#include "mace/utils/logging.h"
#include "mace/utils/logging.h"
#include "mace/utils/memory.h"
#include "mace/utils/string_util.h"
#include "mace/utils/string_util.h"
#ifdef MODEL_GRAPH_FORMAT_CODE
#ifdef MODEL_GRAPH_FORMAT_CODE
...
@@ -244,7 +245,8 @@ bool RunModel(const std::string &model_name,
...
@@ -244,7 +245,8 @@ bool RunModel(const std::string &model_name,
}
}
#endif // MACE_ENABLE_OPENCL
#endif // MACE_ENABLE_OPENCL
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_graph_data
;
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_graph_data
=
make_unique
<
mace
::
port
::
ReadOnlyBufferMemoryRegion
>
();
if
(
FLAGS_model_file
!=
""
)
{
if
(
FLAGS_model_file
!=
""
)
{
auto
fs
=
GetFileSystem
();
auto
fs
=
GetFileSystem
();
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
FLAGS_model_file
.
c_str
(),
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
FLAGS_model_file
.
c_str
(),
...
@@ -254,7 +256,8 @@ bool RunModel(const std::string &model_name,
...
@@ -254,7 +256,8 @@ bool RunModel(const std::string &model_name,
}
}
}
}
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_weights_data
;
std
::
unique_ptr
<
mace
::
port
::
ReadOnlyMemoryRegion
>
model_weights_data
=
make_unique
<
mace
::
port
::
ReadOnlyBufferMemoryRegion
>
();
if
(
FLAGS_model_data_file
!=
""
)
{
if
(
FLAGS_model_data_file
!=
""
)
{
auto
fs
=
GetFileSystem
();
auto
fs
=
GetFileSystem
();
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
FLAGS_model_data_file
.
c_str
(),
status
=
fs
->
NewReadOnlyMemoryRegionFromFile
(
FLAGS_model_data_file
.
c_str
(),
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录