Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
项目经理老王
Mace
提交
200ac9cb
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,发现更多精彩内容 >>
提交
200ac9cb
编写于
9月 11, 2018
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update the document with latest APIs.
上级
ac79ea41
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
42 addition
and
31 deletion
+42
-31
docs/user_guide/advanced_usage.rst
docs/user_guide/advanced_usage.rst
+19
-9
docs/user_guide/basic_usage.rst
docs/user_guide/basic_usage.rst
+20
-13
mace/core/net.cc
mace/core/net.cc
+0
-3
mace/core/runtime/opencl/opencl_runtime.cc
mace/core/runtime/opencl/opencl_runtime.cc
+1
-0
mace/examples/cli/example.cc
mace/examples/cli/example.cc
+2
-2
mace/ops/ops_test_util.h
mace/ops/ops_test_util.h
+0
-4
未找到文件。
docs/user_guide/advanced_usage.rst
浏览文件 @
200ac9cb
...
...
@@ -180,7 +180,6 @@ There are two common advanced use cases:
// Include the headers
#include "mace/public/mace.h"
#include "mace/public/mace_runtime.h"
// If the model_graph_format is code
#include "mace/public/${model_name}.h"
#include "mace/public/mace_engine_factory.h"
...
...
@@ -199,7 +198,7 @@ There are two common advanced use cases:
device_type,
&engine);
if (create_engine_status != MaceStatus::MACE_SUCCESS) {
// Report error
// Report error
or fallback
}
// ... Same with the code in basic usage
...
...
@@ -271,13 +270,24 @@ There are two common advanced use cases:
// Include the headers
#include "mace/public/mace.h"
#include "mace/public/mace_runtime.h"
// 0. Set pre-compiled OpenCL binary program file paths and OpenCL parameters file path when available
if (device_type == DeviceType::GPU) {
mace::SetOpenCLBinaryPaths(path/to/opencl_binary_paths);
mace::SetOpenCLParameterPath(path/to/opencl_parameter_file);
}
// 0. Declare the device type (must be same with ``runtime`` in configuration file)
DeviceType device_type = DeviceType::GPU;
// 1. configuration
MaceStatus status;
MaceEngineConfig config(device_type);
std::shared_ptr<GPUContext> gpu_context;
const std::string storage_path ="path/to/storage";
gpu_context = GPUContextBuilder()
.SetStoragePath(storage_path)
.SetOpenCLBinaryPaths(path/to/opencl_binary_paths)
.SetOpenCLParameterPath(path/to/opencl_parameter_file)
.Finalize();
config.SetGPUContext(gpu_context);
config.SetGPUHints(
static_cast<GPUPerfHint>(GPUPerfHint::PERF_NORMAL),
static_cast<GPUPriorityHint>(GPUPriorityHint::PRIORITY_LOW));
// ... Same with the code in basic usage.
...
...
docs/user_guide/basic_usage.rst
浏览文件 @
200ac9cb
...
...
@@ -332,21 +332,28 @@ Please refer to \ ``mace/examples/example.cc``\ for full usage. The following li
// Include the headers
#include "mace/public/mace.h"
#include "mace/public/mace_runtime.h"
// 0. Set compiled OpenCL kernel cache, this is used to reduce the
// initialization time since the compiling is too slow. It's suggested
// to set this even when pre-compiled OpenCL program file is provided
// because the OpenCL version upgrade may also leads to kernel
// recompilations.
const std::string file_path ="path/to/opencl_cache_file";
std::shared_ptr<KVStorageFactory> storage_factory(
new FileStorageFactory(file_path));
ConfigKVStorageFactory(storage_factory);
// 1. Declare the device type (must be same with ``runtime`` in configuration file)
// 0. Declare the device type (must be same with ``runtime`` in configuration file)
DeviceType device_type = DeviceType::GPU;
// 1. configuration
MaceStatus status;
MaceEngineConfig config(device_type);
std::shared_ptr<GPUContext> gpu_context;
// Set the path to store compiled OpenCL kernel binaries.
// please make sure your application have read/write rights of the directory.
// this is used to reduce the initialization time since the compiling is too slow.
// It's suggested to set this even when pre-compiled OpenCL program file is provided
// because the OpenCL version upgrade may also leads to kernel recompilations.
const std::string storage_path ="path/to/storage";
gpu_context = GPUContextBuilder()
.SetStoragePath(storage_path)
.Finalize();
config.SetGPUContext(gpu_context);
config.SetGPUHints(
static_cast<GPUPerfHint>(GPUPerfHint::PERF_NORMAL),
static_cast<GPUPriorityHint>(GPUPriorityHint::PRIORITY_LOW));
// 2. Define the input and output tensor names.
std::vector<std::string> input_names = {...};
std::vector<std::string> output_names = {...};
...
...
mace/core/net.cc
浏览文件 @
200ac9cb
...
...
@@ -87,9 +87,6 @@ MaceStatus SerialNet::Run(RunMetadata *run_metadata) {
}
else
{
future
.
wait_fn
(
nullptr
);
}
#ifdef MACE_ENABLE_OPENCL
device_
->
opencl_runtime
()
->
command_queue
().
finish
();
#endif
}
else
if
(
run_metadata
!=
nullptr
)
{
call_stats
.
start_micros
=
NowMicros
();
MACE_RETURN_IF_ERROR
(
op
->
Run
(
nullptr
));
...
...
mace/core/runtime/opencl/opencl_runtime.cc
浏览文件 @
200ac9cb
...
...
@@ -441,6 +441,7 @@ OpenCLRuntime::OpenCLRuntime(
}
OpenCLRuntime
::~
OpenCLRuntime
()
{
command_queue_
->
finish
();
built_program_map_
.
clear
();
// We need to control the destruction order, which has dependencies
command_queue_
.
reset
();
...
...
mace/examples/cli/example.cc
浏览文件 @
200ac9cb
...
...
@@ -120,8 +120,8 @@ DEFINE_string(device, "GPU", "CPU/GPU/HEXAGON");
DEFINE_int32
(
round
,
1
,
"round"
);
DEFINE_int32
(
restart_round
,
1
,
"restart round"
);
DEFINE_int32
(
malloc_check_cycle
,
-
1
,
"malloc debug check cycle, -1 to disable"
);
DEFINE_int32
(
gpu_perf_hint
,
3
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_priority_hint
,
3
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_perf_hint
,
2
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
gpu_priority_hint
,
1
,
"0:DEFAULT/1:LOW/2:NORMAL/3:HIGH"
);
DEFINE_int32
(
omp_num_threads
,
-
1
,
"num of openmp threads"
);
DEFINE_int32
(
cpu_affinity_policy
,
1
,
"0:AFFINITY_NONE/1:AFFINITY_BIG_ONLY/2:AFFINITY_LITTLE_ONLY"
);
...
...
mace/ops/ops_test_util.h
浏览文件 @
200ac9cb
...
...
@@ -131,10 +131,6 @@ class OpsTestNet {
op_registry_
(
new
OperatorRegistry
())
{
}
~
OpsTestNet
()
{
Sync
();
}
template
<
DeviceType
D
,
typename
T
>
void
AddInputFromArray
(
const
std
::
string
&
name
,
const
std
::
vector
<
index_t
>
&
shape
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录