Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
ee725558
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,发现更多精彩内容 >>
提交
ee725558
编写于
12月 21, 2017
作者:
L
Liangliang He
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'mace-api' into 'master'
Add version api. See merge request !176
上级
2e249cc4
5b7ac7f3
变更
39
隐藏空白更改
内联
并排
Showing
39 changed file
with
147 addition
and
60 deletion
+147
-60
mace/BUILD
mace/BUILD
+8
-0
mace/codegen/BUILD
mace/codegen/BUILD
+11
-0
mace/core/BUILD
mace/core/BUILD
+1
-1
mace/core/allocator.h
mace/core/allocator.h
+1
-1
mace/core/arg_helper.h
mace/core/arg_helper.h
+1
-1
mace/core/mace.cc
mace/core/mace.cc
+2
-3
mace/core/net.h
mace/core/net.h
+1
-1
mace/core/operator.h
mace/core/operator.h
+1
-1
mace/core/public/mace.h
mace/core/public/mace.h
+0
-0
mace/core/public/version.h
mace/core/public/version.h
+26
-0
mace/core/serializer.h
mace/core/serializer.h
+1
-1
mace/core/tensor.h
mace/core/tensor.h
+1
-1
mace/core/types.h
mace/core/types.h
+1
-1
mace/core/workspace.h
mace/core/workspace.h
+1
-1
mace/examples/BUILD
mace/examples/BUILD
+4
-4
mace/examples/mace_run.cc
mace/examples/mace_run.cc
+6
-2
mace/kernels/BUILD
mace/kernels/BUILD
+5
-5
mace/kernels/batch_norm.h
mace/kernels/batch_norm.h
+1
-1
mace/kernels/bias_add.h
mace/kernels/bias_add.h
+1
-1
mace/kernels/concat.h
mace/kernels/concat.h
+1
-1
mace/kernels/depthwise_conv2d.h
mace/kernels/depthwise_conv2d.h
+1
-1
mace/kernels/space_to_batch.h
mace/kernels/space_to_batch.h
+1
-1
mace/mace.bzl
mace/mace.bzl
+6
-0
mace/ops/BUILD
mace/ops/BUILD
+3
-2
mace/ops/addn.cc
mace/ops/addn.cc
+2
-2
mace/ops/batch_norm.cc
mace/ops/batch_norm.cc
+2
-2
mace/ops/concat.h
mace/ops/concat.h
+0
-1
mace/ops/conv_2d.cc
mace/ops/conv_2d.cc
+2
-2
mace/ops/depthwise_conv2d.cc
mace/ops/depthwise_conv2d.cc
+2
-2
mace/ops/global_avg_pooling.cc
mace/ops/global_avg_pooling.cc
+2
-2
mace/ops/global_avg_pooling.h
mace/ops/global_avg_pooling.h
+1
-1
mace/ops/ops_test_util.h
mace/ops/ops_test_util.h
+1
-0
mace/ops/pooling.cc
mace/ops/pooling.cc
+2
-2
mace/ops/relu.cc
mace/ops/relu.cc
+2
-2
mace/ops/resize_bilinear.cc
mace/ops/resize_bilinear.cc
+2
-2
mace/python/tools/model.template
mace/python/tools/model.template
+3
-3
mace/tools/git/gen_version_source.sh
mace/tools/git/gen_version_source.sh
+24
-0
tools/bazel-adb-run.sh
tools/bazel-adb-run.sh
+5
-1
tools/validate_gcn.sh
tools/validate_gcn.sh
+12
-8
未找到文件。
mace/BUILD
浏览文件 @
ee725558
...
...
@@ -32,6 +32,14 @@ config_setting(
visibility
=
[
"//visibility:public"
],
)
config_setting
(
name
=
"enable_neon"
,
define_values
=
{
"neon"
:
"true"
,
},
visibility
=
[
"//visibility:public"
],
)
config_setting
(
name
=
"embed_binary_program"
,
define_values
=
{
...
...
mace/codegen/BUILD
浏览文件 @
ee725558
...
...
@@ -15,6 +15,7 @@ cc_library(
deps
=
[
"//mace/core"
,
"//mace/ops"
,
'//mace/codegen:version_lib'
,
]
+
if_embed_binary_program
([
'//mace/codegen:generated_opencl_lib'
,
'//mace/codegen:generated_tuning_lib'
,
...
...
@@ -34,3 +35,13 @@ cc_library(
copts
=
[
"-std=c++11"
,
"-D_GLIBCXX_USE_C99_MATH_TR1"
],
linkstatic
=
1
,
)
cc_library
(
name
=
"version_lib"
,
srcs
=
glob
([
"version/*.cc"
]),
copts
=
[
"-std=c++11"
,
"-D_GLIBCXX_USE_C99_MATH_TR1"
],
linkstatic
=
1
,
deps
=
[
"//mace/core"
,
]
)
mace/core/BUILD
浏览文件 @
ee725558
...
...
@@ -35,7 +35,7 @@ cc_library(
cc_library
(
name
=
"core"
,
srcs
=
glob
([
"*.cc"
]),
hdrs
=
glob
([
"*.h"
]),
hdrs
=
glob
([
"*.h"
,
"public/*.h"
]),
copts
=
[
"-std=c++11"
,
"-D_GLIBCXX_USE_C99_MATH_TR1"
],
linkopts
=
if_android
([
"-pie"
]),
deps
=
[
...
...
mace/core/allocator.h
浏览文件 @
ee725558
...
...
@@ -9,7 +9,7 @@
#include <malloc.h>
#include "mace/core/common.h"
#include "mace/core/registry.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
#include "mace/core/types.h"
namespace
mace
{
...
...
mace/core/arg_helper.h
浏览文件 @
ee725558
...
...
@@ -8,7 +8,7 @@
#include <map>
#include "mace/core/common.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace
mace
{
...
...
mace/core/mace.cc
浏览文件 @
ee725558
...
...
@@ -2,7 +2,7 @@
// Copyright (c) 2017 XiaoMi All rights reserved.
//
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
#include "mace/core/types.h"
#include "mace/core/net.h"
#include "mace/core/workspace.h"
...
...
@@ -495,8 +495,7 @@ MaceEngine::MaceEngine(const NetDef *net_def, DeviceType device_type):
ws_
->
CreateTensor
(
"mace_input_node:0"
,
GetDeviceAllocator
(
device_type_
),
DT_FLOAT
);
net_
=
std
::
move
(
CreateNet
(
*
net_def
,
ws_
.
get
(),
device_type
));
}
MaceEngine
::~
MaceEngine
()
{
}
MaceEngine
::~
MaceEngine
(){}
const
float
*
MaceEngine
::
Run
(
const
float
*
input
,
const
std
::
vector
<
index_t
>
&
input_shape
,
std
::
vector
<
int64_t
>
&
output_shape
)
{
...
...
mace/core/net.h
浏览文件 @
ee725558
...
...
@@ -6,7 +6,7 @@
#define MACE_CORE_NET_H_
#include "mace/core/common.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace
mace
{
...
...
mace/core/operator.h
浏览文件 @
ee725558
...
...
@@ -11,7 +11,7 @@
#include "mace/core/registry.h"
#include "mace/core/tensor.h"
#include "mace/core/workspace.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace
mace
{
...
...
mace/core/mace.h
→
mace/core/
public/
mace.h
浏览文件 @
ee725558
文件已移动
mace/core/public/version.h
0 → 100644
浏览文件 @
ee725558
//
// Copyright (c) 2017 XiaoMi All rights reserved.
//
#ifndef MACE_CORE_PUBLIC_VERSION_H_
#define MACE_CORE_PUBLIC_VERSION_H_
#define MACE_MAJOR_VERSION 0
#define MACE_MINOR_VERSION 1
#define MACE_PATCH_VERSION 0
// MACE_VERSION_SUFFIX is non-empty for pre-releases (e.g. "-alpha", "-alpha.1",
// "-beta", "-rc", "-rc.1")
#define MACE_VERSION_SUFFIX ""
#define MACE_STR_HELPER(x) #x
#define MACE_STR(x) MACE_STR_HELPER(x)
// e.g. "0.5.0" or "0.6.0-alpha".
#define MACE_VERSION_STRING \
(MACE_STR(MACE_MAJOR_VERSION) "." MACE_STR(MACE_MINOR_VERSION) "." MACE_STR( \
MACE_PATCH_VERSION) MACE_VERSION_SUFFIX)
extern
const
char
*
MaceVersion
();
extern
const
char
*
MaceGitVersion
();
#endif // MACE_CORE_PUBLIC_VERSION_H_
mace/core/serializer.h
浏览文件 @
ee725558
...
...
@@ -7,7 +7,7 @@
#include "mace/core/common.h"
#include "mace/core/tensor.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace
mace
{
...
...
mace/core/tensor.h
浏览文件 @
ee725558
...
...
@@ -9,7 +9,7 @@
#include "mace/core/common.h"
#include "mace/utils/logging.h"
#include "mace/core/types.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace
mace
{
...
...
mace/core/types.h
浏览文件 @
ee725558
...
...
@@ -6,7 +6,7 @@
#define MACE_CORE_TYPES_H_
#include "mace/core/common.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
#include "mace/core/half.h"
...
...
mace/core/workspace.h
浏览文件 @
ee725558
...
...
@@ -7,7 +7,7 @@
#include "mace/core/common.h"
#include "mace/core/tensor.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace
mace
{
...
...
mace/examples/BUILD
浏览文件 @
ee725558
# Examples
load
(
"//mace:mace.bzl"
,
"if_android"
,
"if_embed_binary_program"
)
load
(
"//mace:mace.bzl"
,
"if_android"
,
"if_e
nable_neon"
,
"if_e
mbed_binary_program"
)
cc_binary
(
name
=
"helloworld"
,
...
...
@@ -7,7 +7,7 @@ cc_binary(
"helloworld.cc"
,
],
copts
=
[
"-std=c++11"
,
"-D_GLIBCXX_USE_C99_MATH_TR1"
],
linkopts
=
[
"-fopenmp"
]
,
linkopts
=
if_enable_neon
([
"-fopenmp"
])
,
deps
=
[
"//mace/core"
,
"//mace/ops"
,
...
...
@@ -20,7 +20,7 @@ cc_test(
testonly
=
1
,
srcs
=
[
"benchmark_example.cc"
],
copts
=
[
"-std=c++11"
,
"-D_GLIBCXX_USE_C99_MATH_TR1"
],
linkopts
=
[
"-fopenmp"
]
,
linkopts
=
if_enable_neon
([
"-fopenmp"
])
,
linkstatic
=
1
,
deps
=
[
"//mace/core"
,
...
...
@@ -32,7 +32,7 @@ cc_binary(
name
=
"mace_run"
,
srcs
=
[
"mace_run.cc"
],
copts
=
[
"-std=c++11"
,
"-D_GLIBCXX_USE_C99_MATH_TR1"
],
linkopts
=
[
"-fopenmp"
]
,
linkopts
=
if_enable_neon
([
"-fopenmp"
])
,
linkstatic
=
1
,
deps
=
[
"//mace/codegen:generated_models_lib"
,
...
...
mace/examples/mace_run.cc
浏览文件 @
ee725558
...
...
@@ -17,10 +17,12 @@
#include <iostream>
#include <cstdlib>
#include "mace/utils/command_line_flags.h"
#include "mace/core/mace.h"
#include "mace/utils/logging.h"
#include "mace/utils/env_time.h"
#include "mace/core/public/mace.h"
#include "mace/core/public/version.h"
using
namespace
std
;
using
namespace
mace
;
...
...
@@ -82,7 +84,9 @@ int main(int argc, char **argv) {
return
-
1
;
}
VLOG
(
0
)
<<
"model: "
<<
model_file
<<
std
::
endl
VLOG
(
0
)
<<
"mace version: "
<<
MaceVersion
()
<<
std
::
endl
<<
"mace git version: "
<<
MaceGitVersion
()
<<
std
::
endl
<<
"model: "
<<
model_file
<<
std
::
endl
<<
"input: "
<<
input_node
<<
std
::
endl
<<
"output: "
<<
output_node
<<
std
::
endl
<<
"input_shape: "
<<
input_shape
<<
std
::
endl
...
...
mace/kernels/BUILD
浏览文件 @
ee725558
...
...
@@ -7,22 +7,22 @@ package(
licenses
([
"notice"
])
# Apache 2.0
load
(
"//mace:mace.bzl"
,
"if_android"
,
"if_
android_arm64
"
,
"if_embed_binary_program"
)
load
(
"//mace:mace.bzl"
,
"if_android"
,
"if_
enable_neon
"
,
"if_embed_binary_program"
)
cc_library
(
name
=
"kernels"
,
srcs
=
glob
([
"*.cc"
,
"opencl/*.cc"
])
+
if_
android_arm64
(
glob
([
srcs
=
glob
([
"*.cc"
,
"opencl/*.cc"
])
+
if_
enable_neon
(
glob
([
"neon/*.cc"
,
])),
hdrs
=
glob
([
"*.h"
,
"opencl/*.h"
])
+
if_
android_arm64
(
glob
([
hdrs
=
glob
([
"*.h"
,
"opencl/*.h"
])
+
if_
enable_neon
(
glob
([
"neon/*.h"
,
])),
copts
=
[
"-std=c++11"
,
"-fopenmp"
,
"-D_GLIBCXX_USE_C99_MATH_TR1"
,
]
+
if_embed_binary_program
([
"-DMACE_EMBED_BINARY_PROGRAM"
]),
if_embed_binary_program
([
"-DMACE_EMBED_BINARY_PROGRAM"
])
+
if_enable_neon
([
"-fopenmp"
]),
linkopts
=
if_android
([
"-lm"
]),
deps
=
[
"//mace/core"
,
...
...
mace/kernels/batch_norm.h
浏览文件 @
ee725558
...
...
@@ -7,7 +7,7 @@
#include "mace/core/future.h"
#include "mace/core/tensor.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace
mace
{
namespace
kernels
{
...
...
mace/kernels/bias_add.h
浏览文件 @
ee725558
...
...
@@ -7,7 +7,7 @@
#include "mace/core/future.h"
#include "mace/core/tensor.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace
mace
{
namespace
kernels
{
...
...
mace/kernels/concat.h
浏览文件 @
ee725558
...
...
@@ -8,7 +8,7 @@
#include "mace/core/common.h"
#include "mace/core/future.h"
#include "mace/core/types.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
#include "mace/core/tensor.h"
namespace
mace
{
...
...
mace/kernels/depthwise_conv2d.h
浏览文件 @
ee725558
...
...
@@ -8,7 +8,7 @@
#include "mace/core/future.h"
#include "mace/core/common.h"
#include "mace/kernels/conv_pool_2d_util.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace
mace
{
namespace
kernels
{
...
...
mace/kernels/space_to_batch.h
浏览文件 @
ee725558
...
...
@@ -7,7 +7,7 @@
#include "mace/core/future.h"
#include "mace/core/tensor.h"
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace
mace
{
namespace
kernels
{
...
...
mace/mace.bzl
浏览文件 @
ee725558
...
...
@@ -35,3 +35,9 @@ def if_embed_binary_program(a):
"//mace:embed_binary_program"
:
a
,
"//conditions:default"
:
[],
})
def
if_enable_neon
(
a
):
return
select
({
"//mace:enable_neon"
:
a
,
"//conditions:default"
:
[],
})
mace/ops/BUILD
浏览文件 @
ee725558
...
...
@@ -7,7 +7,7 @@ package(
licenses
([
"notice"
])
# Apache 2.0
load
(
"//mace:mace.bzl"
,
"if_android"
)
load
(
"//mace:mace.bzl"
,
"if_android"
,
"if_enable_neon"
)
cc_library
(
name
=
"test"
,
...
...
@@ -34,7 +34,8 @@ cc_library(
[
"*.h"
],
exclude
=
[
"ops_test_util.h"
],
),
copts
=
[
"-std=c++11"
,
"-D_GLIBCXX_USE_C99_MATH_TR1"
],
copts
=
[
"-std=c++11"
,
"-D_GLIBCXX_USE_C99_MATH_TR1"
]
+
if_enable_neon
([
"-DMACE_ENABLE_NEON"
]),
deps
=
[
"//mace/kernels"
,
],
...
...
mace/ops/addn.cc
浏览文件 @
ee725558
...
...
@@ -11,12 +11,12 @@ REGISTER_CPU_OPERATOR(OpKeyBuilder("AddN")
.
Build
(),
AddNOp
<
DeviceType
::
CPU
,
float
>
);
#if
__ARM
_NEON
#if
MACE_ENABLE
_NEON
REGISTER_NEON_OPERATOR
(
OpKeyBuilder
(
"AddN"
)
.
TypeConstraint
<
float
>
(
"T"
)
.
Build
(),
AddNOp
<
DeviceType
::
NEON
,
float
>
);
#endif //
__ARM
_NEON
#endif //
MACE_ENABLE
_NEON
REGISTER_OPENCL_OPERATOR
(
OpKeyBuilder
(
"AddN"
)
.
TypeConstraint
<
float
>
(
"T"
)
...
...
mace/ops/batch_norm.cc
浏览文件 @
ee725558
...
...
@@ -11,12 +11,12 @@ REGISTER_CPU_OPERATOR(OpKeyBuilder("BatchNorm")
.
Build
(),
BatchNormOp
<
DeviceType
::
CPU
,
float
>
);
#if
__ARM
_NEON
#if
MACE_ENABLE
_NEON
REGISTER_NEON_OPERATOR
(
OpKeyBuilder
(
"BatchNorm"
)
.
TypeConstraint
<
float
>
(
"T"
)
.
Build
(),
BatchNormOp
<
DeviceType
::
NEON
,
float
>
);
#endif //
__ARM
_NEON
#endif //
MACE_ENABLE
_NEON
REGISTER_OPENCL_OPERATOR
(
OpKeyBuilder
(
"BatchNorm"
)
.
TypeConstraint
<
float
>
(
"T"
)
...
...
mace/ops/concat.h
浏览文件 @
ee725558
...
...
@@ -7,7 +7,6 @@
#include "mace/core/operator.h"
#include "mace/kernels/concat.h"
#include "mace/core/mace.h"
namespace
mace
{
template
<
DeviceType
D
,
typename
T
>
...
...
mace/ops/conv_2d.cc
浏览文件 @
ee725558
...
...
@@ -16,12 +16,12 @@ REGISTER_CPU_OPERATOR(OpKeyBuilder("Conv2D")
.
Build
(),
Conv2dOp
<
DeviceType
::
CPU
,
half
>
);
#if
__ARM
_NEON
#if
MACE_ENABLE
_NEON
REGISTER_NEON_OPERATOR
(
OpKeyBuilder
(
"Conv2D"
)
.
TypeConstraint
<
float
>
(
"T"
)
.
Build
(),
Conv2dOp
<
DeviceType
::
NEON
,
float
>
);
#endif //
__ARM
_NEON
#endif //
MACE_ENABLE
_NEON
REGISTER_OPENCL_OPERATOR
(
OpKeyBuilder
(
"Conv2D"
)
.
TypeConstraint
<
float
>
(
"T"
)
...
...
mace/ops/depthwise_conv2d.cc
浏览文件 @
ee725558
...
...
@@ -11,12 +11,12 @@ REGISTER_CPU_OPERATOR(OpKeyBuilder("DepthwiseConv2d")
.
Build
(),
DepthwiseConv2dOp
<
DeviceType
::
CPU
,
float
>
);
#if
__ARM
_NEON
#if
MACE_ENABLE
_NEON
REGISTER_NEON_OPERATOR
(
OpKeyBuilder
(
"DepthwiseConv2d"
)
.
TypeConstraint
<
float
>
(
"T"
)
.
Build
(),
DepthwiseConv2dOp
<
DeviceType
::
NEON
,
float
>
);
#endif //
__ARM
_NEON
#endif //
MACE_ENABLE
_NEON
REGISTER_OPENCL_OPERATOR
(
OpKeyBuilder
(
"DepthwiseConv2d"
)
.
TypeConstraint
<
float
>
(
"T"
)
...
...
mace/ops/global_avg_pooling.cc
浏览文件 @
ee725558
...
...
@@ -11,11 +11,11 @@ REGISTER_CPU_OPERATOR(OpKeyBuilder("GlobalAvgPooling")
.
Build
(),
GlobalAvgPoolingOp
<
DeviceType
::
CPU
,
float
>
);
#if
__ARM
_NEON
#if
MACE_ENABLE
_NEON
REGISTER_NEON_OPERATOR
(
OpKeyBuilder
(
"GlobalAvgPooling"
)
.
TypeConstraint
<
float
>
(
"T"
)
.
Build
(),
GlobalAvgPoolingOp
<
DeviceType
::
NEON
,
float
>
);
#endif //
__ARM
_NEON
#endif //
MACE_ENABLE
_NEON
}
// namespace mace
mace/ops/global_avg_pooling.h
浏览文件 @
ee725558
//
//
DMACE_ENABLE_NEON
// Copyright (c) 2017 XiaoMi All rights reserved.
//
...
...
mace/ops/ops_test_util.h
浏览文件 @
ee725558
...
...
@@ -11,6 +11,7 @@
#include "mace/core/common.h"
#include "mace/core/net.h"
#include "mace/core/tensor.h"
#include "mace/core/workspace.h"
#include "mace/core/runtime/opencl/opencl_runtime.h"
#include "mace/kernels/opencl/helper.h"
#include "mace/utils/utils.h"
...
...
mace/ops/pooling.cc
浏览文件 @
ee725558
...
...
@@ -15,12 +15,12 @@ REGISTER_CPU_OPERATOR(OpKeyBuilder("Pooling")
.
Build
(),
PoolingOp
<
DeviceType
::
CPU
,
half
>
);
#if
__ARM
_NEON
#if
MACE_ENABLE
_NEON
REGISTER_NEON_OPERATOR
(
OpKeyBuilder
(
"Pooling"
)
.
TypeConstraint
<
float
>
(
"T"
)
.
Build
(),
PoolingOp
<
DeviceType
::
NEON
,
float
>
);
#endif //
__ARM
_NEON
#endif //
MACE_ENABLE
_NEON
REGISTER_OPENCL_OPERATOR
(
OpKeyBuilder
(
"Pooling"
)
.
TypeConstraint
<
float
>
(
"T"
)
...
...
mace/ops/relu.cc
浏览文件 @
ee725558
...
...
@@ -11,12 +11,12 @@ REGISTER_CPU_OPERATOR(OpKeyBuilder("Relu")
.
Build
(),
ReluOp
<
DeviceType
::
CPU
,
float
>
);
#if
__ARM
_NEON
#if
MACE_ENABLE
_NEON
REGISTER_NEON_OPERATOR
(
OpKeyBuilder
(
"Relu"
)
.
TypeConstraint
<
float
>
(
"T"
)
.
Build
(),
ReluOp
<
DeviceType
::
NEON
,
float
>
);
#endif //
__ARM
_NEON
#endif //
MACE_ENABLE
_NEON
REGISTER_OPENCL_OPERATOR
(
OpKeyBuilder
(
"Relu"
)
.
TypeConstraint
<
float
>
(
"T"
)
...
...
mace/ops/resize_bilinear.cc
浏览文件 @
ee725558
...
...
@@ -11,12 +11,12 @@ REGISTER_CPU_OPERATOR(OpKeyBuilder("ResizeBilinear")
.
Build
(),
ResizeBilinearOp
<
DeviceType
::
CPU
,
float
>
);
#if
__ARM
_NEON
#if
MACE_ENABLE
_NEON
REGISTER_NEON_OPERATOR
(
OpKeyBuilder
(
"ResizeBilinear"
)
.
TypeConstraint
<
float
>
(
"T"
)
.
Build
(),
ResizeBilinearOp
<
DeviceType
::
NEON
,
float
>
);
#endif //
__ARM
_NEON
#endif //
MACE_ENABLE
_NEON
REGISTER_OPENCL_OPERATOR
(
OpKeyBuilder
(
"ResizeBilinear"
)
.
TypeConstraint
<
float
>
(
"T"
)
...
...
mace/python/tools/model.template
浏览文件 @
ee725558
...
...
@@ -5,7 +5,7 @@
{% if mode == 0 %}
#include <vector>
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace {{tag}}{
...
...
@@ -24,7 +24,7 @@ void Create{{tensor.name}}(std::vector<mace::TensorProto> &tensors) {
{% elif mode == 1 %}
#include <vector>
#include <string>
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace {
static void UpdateOp(mace::OperatorDef &op,
...
...
@@ -95,7 +95,7 @@ void CreateOperator{{i}}(mace::OperatorDef &op) {
{% else %}
#include <vector>
#include <string>
#include "mace/core/mace.h"
#include "mace/core/
public/
mace.h"
namespace {{tag}} {
...
...
mace/tools/git/gen_version_source.sh
0 → 100644
浏览文件 @
ee725558
#!/usr/bin/env bash
#
# Copyright (c) 2017 XiaoMi All rights reserved.
#
OUTPUT_FILENAME
=
$1
if
[[
-z
"
${
OUTPUT_FILENAME
}
}"
]]
;
then
echo
"Usage:
$0
<filename>"
exit
1
fi
DATE_STR
=
$(
date
+%Y%m%d
)
GIT_VERSION
=
$(
git describe
--long
--tags
)
if
[[
$?
!=
0
]]
;
then
GIT_VERSION
=
unknown
else
GIT_VERSION
=
${
GIT_VERSION
}
-
${
DATE_STR
}
fi
cat
<<
EOF
>
${
OUTPUT_FILENAME
}
#include "mace/core/public/version.h"
const char *MaceVersion() { return MACE_VERSION_STRING; }
const char *MaceGitVersion() { return "
${
GIT_VERSION
}
"; }
EOF
tools/bazel-adb-run.sh
浏览文件 @
ee725558
...
...
@@ -27,7 +27,11 @@ PROFILINE="--define profiling=true"
BRANCH
=
$(
git symbolic-ref
--short
HEAD
)
COMMIT_ID
=
$(
git rev-parse
--short
HEAD
)
bazel build
-c
opt
$STRIP
--verbose_failures
$BAZEL_TARGET
--crosstool_top
=
//external:android/crosstool
--host_crosstool_top
=
@bazel_tools//tools/cpp:toolchain
--cpu
=
$ANDROID_ABI
bazel build
-c
opt
$STRIP
--verbose_failures
$BAZEL_TARGET
\
--crosstool_top
=
//external:android/crosstool
\
--host_crosstool_top
=
@bazel_tools//tools/cpp:toolchain
\
--cpu
=
$ANDROID_ABI
\
--define
neon
=
true
if
[
$?
-ne
0
]
;
then
exit
1
...
...
tools/validate_gcn.sh
浏览文件 @
ee725558
...
...
@@ -27,6 +27,7 @@ CL_CODEGEN_DIR=${CODEGEN_DIR}/opencl
CL_BIN_DIR
=
${
CODEGEN_DIR
}
/opencl_bin
TUNING_CODEGEN_DIR
=
${
CODEGEN_DIR
}
/tuning
TUNING_OR_NOT
=
${
3
:-
0
}
VERSION_SOURCE_PATH
=
${
CODEGEN_DIR
}
/version
build_and_run
()
{
...
...
@@ -50,7 +51,6 @@ build_and_run()
adb push
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
${
PHONE_DATA_DIR
}
adb push bazel-bin/mace/examples/mace_run
${
PHONE_DATA_DIR
}
num_threads
=
${
1
:-
4
}
if
[[
"
${
TUNING_OR_NOT
}
"
!=
"0"
&&
"
$EMBED_OPENCL_BINARY
"
!=
true
]]
;
then
tuning_flag
=
1
round
=
0
# only warm up
...
...
@@ -63,7 +63,6 @@ build_and_run()
MACE_CPP_MIN_VLOG_LEVEL
=
0
\
MACE_RUN_PARAMETER_PATH
=
${
PHONE_DATA_DIR
}
/mace_run.config
\
MACE_KERNEL_PATH
=
$KERNEL_DIR
\
OMP_NUM_THREADS
=
$num_threads
\
${
PHONE_DATA_DIR
}
/mace_run
\
--model
=
${
PHONE_DATA_DIR
}
/
${
MACE_MODEL_NAME
}
\
--input
=
mace_input_node
\
...
...
@@ -95,10 +94,15 @@ bazel-bin/mace/python/tools/tf_converter --input=${TF_MODEL_FILE_PATH} \
--model_tag
=
${
MODEL_TAG
}
\
--confuse
=
True
echo
"Step 3: Run model on the phone with files"
echo
"Step 3: Generate version source"
rm
-rf
${
VERSION_SOURCE_PATH
}
mkdir
-p
${
VERSION_SOURCE_PATH
}
bash mace/tools/git/gen_version_source.sh
${
VERSION_SOURCE_PATH
}
/version.cc
echo
"Step 4: Run model on the phone with files"
build_and_run
false
echo
"Step
4
: Generate OpenCL binary program and config code"
echo
"Step
5
: Generate OpenCL binary program and config code"
rm
-rf
${
CL_BIN_DIR
}
adb pull
${
KERNEL_DIR
}
${
CL_BIN_DIR
}
rm
-rf
${
CL_CODEGEN_DIR
}
...
...
@@ -106,20 +110,20 @@ mkdir -p ${CL_CODEGEN_DIR}
python mace/python/tools/opencl_codegen.py
\
--cl_binary_dir
=
${
CL_BIN_DIR
}
--output_path
=
${
CL_CODEGEN_DIR
}
/opencl_compiled_program.cc
echo
"Step
5
: Generate tuning source file"
echo
"Step
6
: Generate tuning source file"
adb pull
${
PHONE_DATA_DIR
}
/mace_run.config
${
CL_BIN_DIR
}
mkdir
-p
${
TUNING_CODEGEN_DIR
}
python mace/python/tools/binary_codegen.py
\
--binary_file
=
${
CL_BIN_DIR
}
/mace_run.config
--output_path
=
${
TUNING_CODEGEN_DIR
}
/tuning_params.cc
echo
"Step
6
: Run model on the phone using binary"
echo
"Step
7
: Run model on the phone using binary"
build_and_run
true
echo
"Step
7
: Pull the mace run result."
echo
"Step
8
: Pull the mace run result."
rm
-rf
${
MODEL_DIR
}
/
${
OUTPUT_FILE_NAME
}
adb </dev/null pull
${
PHONE_DATA_DIR
}
/
${
OUTPUT_FILE_NAME
}
${
MODEL_DIR
}
echo
"Step
8
: Validate the result"
echo
"Step
9
: Validate the result"
python tools/validate.py
--model_file
${
TF_MODEL_FILE_PATH
}
\
--input_file
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
\
--mace_out_file
${
MODEL_DIR
}
/
${
OUTPUT_FILE_NAME
}
\
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录