Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
野马c
Mace
提交
b85977e8
Mace
项目概览
野马c
/
Mace
与 Fork 源项目一致
Fork自
Xiaomi / Mace
通知
1
Star
1
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,发现更多精彩内容 >>
提交
b85977e8
编写于
11月 15, 2017
作者:
L
liuqi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor the core BUILD file for better dependencies.
上级
ba4ca883
变更
9
显示空白变更内容
内联
并排
Showing
9 changed file
with
55 addition
and
26 deletion
+55
-26
mace/core/BUILD
mace/core/BUILD
+28
-8
mace/core/allocator.cc
mace/core/allocator.cc
+2
-0
mace/core/net.cc
mace/core/net.cc
+4
-1
mace/core/net.h
mace/core/net.h
+1
-0
mace/core/opencl_allocator.cc
mace/core/opencl_allocator.cc
+1
-2
mace/core/opencl_allocator.h
mace/core/opencl_allocator.h
+0
-0
mace/kernels/BUILD
mace/kernels/BUILD
+0
-1
mace/ops/BUILD
mace/ops/BUILD
+0
-1
mace/tools/benchmark/benchmark_model.cc
mace/tools/benchmark/benchmark_model.cc
+19
-13
未找到文件。
mace/core/BUILD
浏览文件 @
b85977e8
...
...
@@ -21,26 +21,46 @@ cc_library(
]),
copts
=
[
"-std=c++11"
],
deps
=
[
"
core
"
,
"
:logging
"
,
"@opencl_headers//:opencl20_headers"
,
],
alwayslink
=
1
,
)
cc_library
(
name
=
"logging"
,
srcs
=
[
"logging.cc"
,
],
hdrs
=
[
"logging.h"
,
],
copts
=
[
"-std=c++11"
],
linkopts
=
if_android
([
"-llog"
,
]),
)
cc_library
(
name
=
"core"
,
srcs
=
glob
([
"*.cc"
,
srcs
=
glob
(
[
"*.cc"
,],
exclude
=
[
"logging.cc"
]),
hdrs
=
glob
([
"*.h"
,
hdrs
=
glob
(
[
"*.h"
],
exclude
=
[
"logging.h"
]),
copts
=
[
"-std=c++11"
],
linkopts
=
if_android
([
"-llog"
,
"-pie"
,
]),
deps
=
[
":logging"
,
":opencl_runtime"
,
"//mace/proto:cc_proto"
,
"//mace/proto:stats_proto"
,
"//mace/utils"
,
...
...
mace/core/allocator.cc
浏览文件 @
b85977e8
...
...
@@ -3,6 +3,7 @@
//
#include "mace/core/allocator.h"
#include "mace/core/opencl_allocator.h"
namespace
mace
{
...
...
@@ -22,5 +23,6 @@ Allocator *GetDeviceAllocator(DeviceType type) {
MACE_REGISTER_ALLOCATOR
(
DeviceType
::
CPU
,
new
CPUAllocator
());
MACE_REGISTER_ALLOCATOR
(
DeviceType
::
NEON
,
new
CPUAllocator
());
MACE_REGISTER_ALLOCATOR
(
DeviceType
::
OPENCL
,
new
OpenCLAllocator
());
}
// namespace mace
mace/core/net.cc
浏览文件 @
b85977e8
...
...
@@ -4,6 +4,7 @@
#include "mace/core/net.h"
#include "mace/utils/utils.h"
#include "mace/core/runtime/opencl/opencl_runtime.h"
namespace
mace
{
...
...
@@ -15,7 +16,7 @@ NetBase::NetBase(const std::shared_ptr<const NetDef> &net_def,
SimpleNet
::
SimpleNet
(
const
std
::
shared_ptr
<
const
NetDef
>
&
net_def
,
Workspace
*
ws
,
DeviceType
type
)
:
NetBase
(
net_def
,
ws
,
type
)
{
:
NetBase
(
net_def
,
ws
,
type
)
,
device_type_
(
type
)
{
VLOG
(
1
)
<<
"Constructing SimpleNet "
<<
net_def
->
name
();
for
(
int
idx
=
0
;
idx
<
net_def
->
op_size
();
++
idx
)
{
const
auto
&
operator_def
=
net_def
->
op
(
idx
);
...
...
@@ -47,6 +48,8 @@ bool SimpleNet::Run(RunMetadata *run_metadata) {
LOG
(
ERROR
)
<<
"Operator failed: "
<<
ProtoDebugString
(
op
->
debug_def
());
return
false
;
}
if
(
device_type_
==
DeviceType
::
OPENCL
)
OpenCLRuntime
::
Get
()
->
command_queue
().
finish
();
if
(
op_stats
)
{
op_stats
->
set_op_end_rel_micros
(
NowInMicroSec
()
-
op_stats
->
all_start_micros
());
...
...
mace/core/net.h
浏览文件 @
b85977e8
...
...
@@ -40,6 +40,7 @@ class SimpleNet : public NetBase {
protected:
vector
<
unique_ptr
<
OperatorBase
>
>
operators_
;
DeviceType
device_type_
;
DISABLE_COPY_AND_ASSIGN
(
SimpleNet
);
};
...
...
mace/core/
runtime/opencl/
opencl_allocator.cc
→
mace/core/opencl_allocator.cc
浏览文件 @
b85977e8
...
...
@@ -3,7 +3,7 @@
//
#include "mace/core/runtime/opencl/cl2_header.h"
#include "mace/core/
runtime/opencl/
opencl_allocator.h"
#include "mace/core/opencl_allocator.h"
#include "mace/core/runtime/opencl/opencl_runtime.h"
namespace
mace
{
...
...
@@ -49,6 +49,5 @@ void OpenCLAllocator::Unmap(void *buffer, void *mapped_ptr) {
bool
OpenCLAllocator
::
OnHost
()
{
return
false
;
}
MACE_REGISTER_ALLOCATOR
(
DeviceType
::
OPENCL
,
new
OpenCLAllocator
());
}
// namespace mace
mace/core/
runtime/opencl/
opencl_allocator.h
→
mace/core/opencl_allocator.h
浏览文件 @
b85977e8
文件已移动
mace/kernels/BUILD
浏览文件 @
b85977e8
...
...
@@ -20,7 +20,6 @@ cc_library(
linkopts
=
if_android
([
"-lm"
]),
deps
=
[
"//mace/core"
,
"//mace/core:opencl_runtime"
,
"//mace/utils"
,
"//mace/utils:tuner"
,
],
...
...
mace/ops/BUILD
浏览文件 @
b85977e8
...
...
@@ -17,7 +17,6 @@ cc_library(
],
deps
=
[
"//mace/core"
,
"//mace/core:opencl_runtime"
,
"@gtest//:gtest"
,
],
)
...
...
mace/tools/benchmark/benchmark_model.cc
浏览文件 @
b85977e8
...
...
@@ -42,6 +42,7 @@ bool SplitAndParseToInts(const string &str,
tmp
=
tmp
.
substr
(
next_offset
+
1
);
}
}
return
true
;
}
}
// namespace str_util
...
...
@@ -254,6 +255,10 @@ int Main(int argc, char **argv) {
stats_options
.
show_summary
=
show_summary
;
stats
.
reset
(
new
StatSummarizer
(
stats_options
));
DeviceType
device_type
;
DeviceType_Parse
(
device
,
&
device_type
);
VLOG
(
0
)
<<
device_type
;
// load model
std
::
ifstream
model_file_stream
(
model_file
,
std
::
ios
::
in
|
std
::
ios
::
binary
);
if
(
!
model_file_stream
.
is_open
())
{
...
...
@@ -265,14 +270,16 @@ int Main(int argc, char **argv) {
model_file_stream
.
close
();
Workspace
ws
;
ws
.
LoadModelTensor
(
net_def
,
DeviceType
::
CPU
);
ws
.
LoadModelTensor
(
net_def
,
device_type
);
// Load inputs
for
(
size_t
i
=
0
;
i
<
inputs_count
;
++
i
)
{
Tensor
*
input_tensor
=
ws
.
CreateTensor
(
input_layers
[
i
],
GetDeviceAllocator
(
DeviceType
::
CPU
),
DT_FLOAT
);
ws
.
CreateTensor
(
input_layers
[
i
],
GetDeviceAllocator
(
device_type
),
DT_FLOAT
);
vector
<
index_t
>
shapes
;
str_util
::
SplitAndParseToInts
(
input_layer_shapes
[
i
],
','
,
&
shapes
);
input_tensor
->
Resize
(
shapes
);
{
Tensor
::
MappingGuard
input_guard
(
input_tensor
);
float
*
input_data
=
input_tensor
->
mutable_data
<
float
>
();
// load input
...
...
@@ -284,10 +291,9 @@ int Main(int argc, char **argv) {
in_file
.
close
();
}
}
}
// create net
DeviceType
device_type
;
DeviceType_Parse
(
device
,
&
device_type
);
auto
net
=
CreateNet
(
net_def
,
&
ws
,
device_type
);
int64_t
warmup_time_us
=
0
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录