Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
毕竟曾有刹那
Mace
提交
c33e59c7
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,发现更多精彩内容 >>
提交
c33e59c7
编写于
10月 23, 2018
作者:
刘
刘琦
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'redefine_GPUContext_life_cycle' into 'master'
redefine GPUContext life cycle See merge request !841
上级
c741936c
03767a01
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
36 addition
and
40 deletion
+36
-40
mace/core/device_context.cc
mace/core/device_context.cc
+6
-6
mace/core/device_context.h
mace/core/device_context.h
+6
-6
mace/core/file_storage.cc
mace/core/file_storage.cc
+4
-5
mace/core/file_storage.h
mace/core/file_storage.h
+2
-2
mace/core/runtime/opencl/gpu_device.cc
mace/core/runtime/opencl/gpu_device.cc
+3
-3
mace/core/runtime/opencl/gpu_device.h
mace/core/runtime/opencl/gpu_device.h
+3
-3
mace/core/runtime/opencl/opencl_runtime.cc
mace/core/runtime/opencl/opencl_runtime.cc
+4
-4
mace/core/runtime/opencl/opencl_runtime.h
mace/core/runtime/opencl/opencl_runtime.h
+6
-6
mace/examples/android/macelibrary/src/main/cpp/image_classify.cc
...amples/android/macelibrary/src/main/cpp/image_classify.cc
+0
-1
mace/public/mace.h
mace/public/mace.h
+2
-4
未找到文件。
mace/core/device_context.cc
浏览文件 @
c33e59c7
...
...
@@ -58,16 +58,16 @@ GPUContext::GPUContext(const std::string &storage_path,
GPUContext
::~
GPUContext
()
=
default
;
KVStorage
*
GPUContext
::
opencl_binary_storage
()
{
return
opencl_binary_storage_
.
get
()
;
std
::
shared_ptr
<
KVStorage
>
GPUContext
::
opencl_binary_storage
()
{
return
opencl_binary_storage_
;
}
KVStorage
*
GPUContext
::
opencl_cache_storage
()
{
return
opencl_cache_storage_
.
get
()
;
std
::
shared_ptr
<
KVStorage
>
GPUContext
::
opencl_cache_storage
()
{
return
opencl_cache_storage_
;
}
Tuner
<
uint32_t
>
*
GPUContext
::
opencl_tuner
()
{
return
opencl_tuner_
.
get
()
;
std
::
shared_ptr
<
Tuner
<
uint32_t
>>
GPUContext
::
opencl_tuner
()
{
return
opencl_tuner_
;
}
}
// namespace mace
mace/core/device_context.h
浏览文件 @
c33e59c7
...
...
@@ -32,15 +32,15 @@ class GPUContext {
const
std
::
string
&
opencl_parameter_path
=
""
);
~
GPUContext
();
KVStorage
*
opencl_binary_storage
();
KVStorage
*
opencl_cache_storage
();
Tuner
<
uint32_t
>
*
opencl_tuner
();
std
::
shared_ptr
<
KVStorage
>
opencl_binary_storage
();
std
::
shared_ptr
<
KVStorage
>
opencl_cache_storage
();
std
::
shared_ptr
<
Tuner
<
uint32_t
>>
opencl_tuner
();
private:
std
::
unique_ptr
<
KVStorageFactory
>
storage_factory_
;
std
::
unique
_ptr
<
Tuner
<
uint32_t
>>
opencl_tuner_
;
std
::
unique
_ptr
<
KVStorage
>
opencl_binary_storage_
;
std
::
unique
_ptr
<
KVStorage
>
opencl_cache_storage_
;
std
::
shared
_ptr
<
Tuner
<
uint32_t
>>
opencl_tuner_
;
std
::
shared
_ptr
<
KVStorage
>
opencl_binary_storage_
;
std
::
shared
_ptr
<
KVStorage
>
opencl_cache_storage_
;
};
}
// namespace mace
...
...
mace/core/file_storage.cc
浏览文件 @
c33e59c7
...
...
@@ -32,7 +32,7 @@ class FileStorageFactory::Impl {
public:
explicit
Impl
(
const
std
::
string
&
path
);
std
::
unique
_ptr
<
KVStorage
>
CreateStorage
(
const
std
::
string
&
name
);
std
::
shared
_ptr
<
KVStorage
>
CreateStorage
(
const
std
::
string
&
name
);
private:
std
::
string
path_
;
...
...
@@ -40,10 +40,9 @@ class FileStorageFactory::Impl {
FileStorageFactory
::
Impl
::
Impl
(
const
std
::
string
&
path
)
:
path_
(
path
)
{}
std
::
unique
_ptr
<
KVStorage
>
FileStorageFactory
::
Impl
::
CreateStorage
(
std
::
shared
_ptr
<
KVStorage
>
FileStorageFactory
::
Impl
::
CreateStorage
(
const
std
::
string
&
name
)
{
return
std
::
move
(
std
::
unique_ptr
<
KVStorage
>
(
new
FileStorage
(
path_
+
"/"
+
name
)));
return
std
::
shared_ptr
<
KVStorage
>
(
new
FileStorage
(
path_
+
"/"
+
name
));
}
FileStorageFactory
::
FileStorageFactory
(
const
std
::
string
&
path
)
:
...
...
@@ -51,7 +50,7 @@ FileStorageFactory::FileStorageFactory(const std::string &path):
FileStorageFactory
::~
FileStorageFactory
()
=
default
;
std
::
unique
_ptr
<
KVStorage
>
FileStorageFactory
::
CreateStorage
(
std
::
shared
_ptr
<
KVStorage
>
FileStorageFactory
::
CreateStorage
(
const
std
::
string
&
name
)
{
return
impl_
->
CreateStorage
(
name
);
}
...
...
mace/core/file_storage.h
浏览文件 @
c33e59c7
...
...
@@ -41,7 +41,7 @@ class KVStorage {
class
KVStorageFactory
{
public:
virtual
std
::
unique
_ptr
<
KVStorage
>
CreateStorage
(
const
std
::
string
&
name
)
=
0
;
virtual
std
::
shared
_ptr
<
KVStorage
>
CreateStorage
(
const
std
::
string
&
name
)
=
0
;
virtual
~
KVStorageFactory
()
{}
};
...
...
@@ -53,7 +53,7 @@ class FileStorageFactory : public KVStorageFactory {
~
FileStorageFactory
();
std
::
unique
_ptr
<
KVStorage
>
CreateStorage
(
const
std
::
string
&
name
)
override
;
std
::
shared
_ptr
<
KVStorage
>
CreateStorage
(
const
std
::
string
&
name
)
override
;
private:
class
Impl
;
...
...
mace/core/runtime/opencl/gpu_device.cc
浏览文件 @
c33e59c7
...
...
@@ -18,11 +18,11 @@
namespace
mace
{
GPUDevice
::
GPUDevice
(
Tuner
<
uint32_t
>
*
tuner
,
KVStorage
*
opencl_cache_storage
,
GPUDevice
::
GPUDevice
(
std
::
shared_ptr
<
Tuner
<
uint32_t
>>
tuner
,
std
::
shared_ptr
<
KVStorage
>
opencl_cache_storage
,
const
GPUPriorityHint
priority
,
const
GPUPerfHint
perf
,
KVStorage
*
opencl_binary_storage
,
std
::
shared_ptr
<
KVStorage
>
opencl_binary_storage
,
const
int
num_threads
,
CPUAffinityPolicy
cpu_affinity_policy
,
bool
use_gemmlowp
)
:
...
...
mace/core/runtime/opencl/gpu_device.h
浏览文件 @
c33e59c7
...
...
@@ -25,11 +25,11 @@ namespace mace {
class
GPUDevice
:
public
CPUDevice
{
public:
GPUDevice
(
Tuner
<
uint32_t
>
*
tuner
,
KVStorage
*
opencl_cache_storage
=
nullptr
,
GPUDevice
(
std
::
shared_ptr
<
Tuner
<
uint32_t
>>
tuner
,
std
::
shared_ptr
<
KVStorage
>
opencl_cache_storage
=
nullptr
,
const
GPUPriorityHint
priority
=
GPUPriorityHint
::
PRIORITY_LOW
,
const
GPUPerfHint
perf
=
GPUPerfHint
::
PERF_NORMAL
,
KVStorage
*
opencl_binary_storage
=
nullptr
,
std
::
shared_ptr
<
KVStorage
>
opencl_binary_storage
=
nullptr
,
const
int
num_threads
=
-
1
,
CPUAffinityPolicy
cpu_affinity_policy
=
AFFINITY_NONE
,
bool
use_gemmlowp
=
false
);
...
...
mace/core/runtime/opencl/opencl_runtime.cc
浏览文件 @
c33e59c7
...
...
@@ -273,11 +273,11 @@ void OpenCLProfilingTimer::ClearTiming() {
}
OpenCLRuntime
::
OpenCLRuntime
(
KVStorage
*
cache_storage
,
std
::
shared_ptr
<
KVStorage
>
cache_storage
,
const
GPUPriorityHint
priority_hint
,
const
GPUPerfHint
perf_hint
,
KVStorage
*
precompiled_binary_storage
,
Tuner
<
uint32_t
>
*
tuner
)
:
std
::
shared_ptr
<
KVStorage
>
precompiled_binary_storage
,
std
::
shared_ptr
<
Tuner
<
uint32_t
>>
tuner
)
:
cache_storage_
(
cache_storage
),
precompiled_binary_storage_
(
precompiled_binary_storage
),
tuner_
(
tuner
),
...
...
@@ -460,7 +460,7 @@ cl::Device &OpenCLRuntime::device() { return *device_; }
cl
::
CommandQueue
&
OpenCLRuntime
::
command_queue
()
{
return
*
command_queue_
;
}
Tuner
<
uint32_t
>
*
OpenCLRuntime
::
tuner
()
{
return
tuner_
;
}
Tuner
<
uint32_t
>
*
OpenCLRuntime
::
tuner
()
{
return
tuner_
.
get
()
;
}
uint64_t
OpenCLRuntime
::
device_global_mem_cache_size
()
const
{
return
device_gloabl_mem_cache_size_
;
...
...
mace/core/runtime/opencl/opencl_runtime.h
浏览文件 @
c33e59c7
...
...
@@ -65,11 +65,11 @@ const std::string OpenCLErrorToString(cl_int error);
class
OpenCLRuntime
{
public:
OpenCLRuntime
(
KVStorage
*
cache_storage
=
nullptr
,
std
::
shared_ptr
<
KVStorage
>
cache_storage
=
nullptr
,
const
GPUPriorityHint
priority_hint
=
GPUPriorityHint
::
PRIORITY_NORMAL
,
const
GPUPerfHint
perf_hint
=
GPUPerfHint
::
PERF_NORMAL
,
KVStorage
*
precompiled_binary_storage
=
nullptr
,
Tuner
<
uint32_t
>
*
tuner
=
nullptr
);
std
::
shared_ptr
<
KVStorage
>
precompiled_binary_storage
=
nullptr
,
std
::
shared_ptr
<
Tuner
<
uint32_t
>>
tuner
=
nullptr
);
~
OpenCLRuntime
();
OpenCLRuntime
(
const
OpenCLRuntime
&
)
=
delete
;
OpenCLRuntime
&
operator
=
(
const
OpenCLRuntime
&
)
=
delete
;
...
...
@@ -126,9 +126,9 @@ class OpenCLRuntime {
OpenCLVersion
ParseDeviceVersion
(
const
std
::
string
&
device_version
);
private:
KVStorage
*
cache_storage_
;
KVStorage
*
precompiled_binary_storage_
;
Tuner
<
uint32_t
>
*
tuner_
;
std
::
shared_ptr
<
KVStorage
>
cache_storage_
;
std
::
shared_ptr
<
KVStorage
>
precompiled_binary_storage_
;
std
::
shared_ptr
<
Tuner
<
uint32_t
>>
tuner_
;
bool
is_opencl_avaliable_
;
bool
is_profiling_enabled_
;
OpenCLVersion
opencl_version_
;
...
...
mace/examples/android/macelibrary/src/main/cpp/image_classify.cc
浏览文件 @
c33e59c7
...
...
@@ -67,7 +67,6 @@ mace::DeviceType ParseDeviceType(const std::string &device) {
}
MaceContext
&
GetMaceContext
()
{
// stay for the app's life time, only initialize once
static
auto
*
mace_context
=
new
MaceContext
;
return
*
mace_context
;
...
...
mace/public/mace.h
浏览文件 @
c33e59c7
...
...
@@ -99,10 +99,8 @@ enum MaceStatus {
/// \brief GPU context contain the status used for GPU device.
///
/// The life cycle of GPUContext object is the same as MaceEngines use it.
/// Just use one GPUContext for all MaceEngines, which will speed up the
/// initialization procedure. There are some data in common between different
/// MaceEngines using GPU, use one GPUContext could avoid duplication.
/// There are some data in common between different MaceEngines using GPU,
/// use one GPUContext could avoid duplication.
class
GPUContext
;
/// \brief GPUContext builder.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录