Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
396a2df4
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,发现更多精彩内容 >>
提交
396a2df4
编写于
3月 19, 2018
作者:
L
Liangliang He
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove out-dated code
上级
fd0a439c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
2 addition
and
133 deletion
+2
-133
mace/examples/BUILD
mace/examples/BUILD
+2
-26
mace/examples/benchmark_example.cc
mace/examples/benchmark_example.cc
+0
-44
mace/examples/helloworld.cc
mace/examples/helloworld.cc
+0
-63
未找到文件。
mace/examples/BUILD
浏览文件 @
396a2df4
# Examples
# Examples
load
(
"//mace:mace.bzl"
,
"if_android"
,
"if_neon_enabled"
,
"if_openmp_enabled"
)
load
(
"//mace:mace.bzl"
,
"if_openmp_enabled"
)
cc_binary
(
name
=
"helloworld"
,
srcs
=
[
"helloworld.cc"
,
],
linkopts
=
if_openmp_enabled
([
"-fopenmp"
]),
deps
=
[
"//mace/core"
,
"//mace/ops"
,
],
)
cc_test
(
name
=
"benchmark_example"
,
testonly
=
1
,
srcs
=
[
"benchmark_example.cc"
],
linkopts
=
if_openmp_enabled
([
"-fopenmp"
]),
linkstatic
=
1
,
deps
=
[
"//mace/core"
,
"//mace/core:test_benchmark_main"
,
],
)
cc_binary
(
cc_binary
(
name
=
"mace_run"
,
name
=
"mace_run"
,
...
@@ -31,7 +7,7 @@ cc_binary(
...
@@ -31,7 +7,7 @@ cc_binary(
linkopts
=
if_openmp_enabled
([
"-fopenmp"
]),
linkopts
=
if_openmp_enabled
([
"-fopenmp"
]),
linkstatic
=
1
,
linkstatic
=
1
,
deps
=
[
deps
=
[
"//mace/codegen:generated_models"
,
"//external:gflags_nothreads"
,
"//external:gflags_nothreads"
,
"//mace/codegen:generated_models"
,
],
],
)
)
mace/examples/benchmark_example.cc
已删除
100644 → 0
浏览文件 @
fd0a439c
//
// Copyright (c) 2017 XiaoMi All rights reserved.
//
#include "mace/core/testing/test_benchmark.h"
static
void
foo
(
int
iters
)
{
static
const
int
N
=
32
;
const
int64_t
tot
=
static_cast
<
int64_t
>
(
iters
)
*
N
;
mace
::
testing
::
MaccProcessed
(
tot
);
mace
::
testing
::
BytesProcessed
(
tot
*
(
sizeof
(
float
)));
float
*
inp
=
new
float
[
N
];
float
*
out
=
new
float
[
N
];
while
(
iters
--
)
{
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
out
[
i
]
=
inp
[
i
]
*
2.0
;
}
}
delete
[]
inp
;
delete
[]
out
;
}
BENCHMARK
(
foo
);
static
void
bar
(
int
iters
,
int
n
)
{
const
int64_t
tot
=
static_cast
<
int64_t
>
(
iters
)
*
n
;
mace
::
testing
::
MaccProcessed
(
tot
);
mace
::
testing
::
BytesProcessed
(
tot
*
(
sizeof
(
float
)));
float
*
inp
=
new
float
[
n
];
float
*
out
=
new
float
[
n
];
while
(
iters
--
)
{
for
(
int
i
=
0
;
i
<
n
;
i
++
)
{
out
[
i
]
=
inp
[
i
]
*
2.0
;
}
}
delete
[]
inp
;
delete
[]
out
;
}
BENCHMARK
(
bar
)
->
Arg
(
32
)
->
Arg
(
64
)
->
Arg
(
128
);
mace/examples/helloworld.cc
已删除
100644 → 0
浏览文件 @
fd0a439c
//
// Copyright (c) 2017 XiaoMi All rights reserved.
//
#include "mace/core/net.h"
#include "mace/core/runtime/opencl/opencl_runtime.h"
using
namespace
mace
;
int
main
()
{
// Construct graph
OperatorDef
op_def_0
;
op_def_0
.
add_input
(
"Input"
);
op_def_0
.
add_output
(
"Output0"
);
op_def_0
.
set_name
(
"ReluTest0"
);
op_def_0
.
set_type
(
"Relu"
);
auto
arg_0
=
op_def_0
.
add_arg
();
arg_0
->
set_name
(
"arg0"
);
arg_0
->
set_f
(
0.5
);
OperatorDef
op_def_1
;
op_def_1
.
add_input
(
"Input"
);
op_def_1
.
add_output
(
"Output1"
);
op_def_1
.
set_name
(
"ReluTest1"
);
op_def_1
.
set_type
(
"Relu"
);
auto
arg_1
=
op_def_1
.
add_arg
();
arg_1
->
set_name
(
"arg0"
);
arg_1
->
set_f
(
1.5
);
OperatorDef
op_def_2
;
op_def_2
.
add_input
(
"Output0"
);
op_def_2
.
add_input
(
"Output1"
);
op_def_2
.
add_output
(
"Output2"
);
op_def_2
.
set_name
(
"AddNTest"
);
op_def_2
.
set_type
(
"AddN"
);
auto
arg_2
=
op_def_2
.
add_arg
();
arg_2
->
set_name
(
"arg0"
);
arg_2
->
set_f
(
2.5
);
NetDef
net_def
;
net_def
.
set_name
(
"NetTest"
);
net_def
.
add_op
()
->
CopyFrom
(
op_def_0
);
net_def
.
add_op
()
->
CopyFrom
(
op_def_1
);
net_def
.
add_op
()
->
CopyFrom
(
op_def_2
);
alignas
(
4
)
unsigned
char
tensor_data
[]
=
"012345678901234567890123"
;
const
std
::
vector
<
int64_t
>
dims
=
{
1
,
2
,
3
,
1
};
ConstTensor
input
(
"Input"
,
tensor_data
,
dims
,
DataType
::
DT_FLOAT
);
net_def
.
mutable_tensors
().
push_back
(
input
);
// Create workspace and input tensor
Workspace
ws
;
ws
.
LoadModelTensor
(
net_def
,
DeviceType
::
CPU
);
// Create Net & run
auto
net
=
CreateNet
(
net_def
,
&
ws
,
DeviceType
::
CPU
);
net
->
Run
();
auto
out_tensor
=
ws
.
GetTensor
(
"Output2"
);
out_tensor
->
DebugPrint
();
return
0
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录