Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Xiaomi
Mace
提交
8d86da87
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,发现更多精彩内容 >>
提交
8d86da87
编写于
1月 03, 2018
作者:
Y
yejianwu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update codegen template, add distribute lib
上级
5553184f
变更
12
显示空白变更内容
内联
并排
Showing
12 changed file
with
194 addition
and
91 deletion
+194
-91
mace/codegen/BUILD
mace/codegen/BUILD
+14
-0
mace/codegen/distribute/use_binary.cc
mace/codegen/distribute/use_binary.cc
+35
-0
mace/codegen/distribute/use_source.cc
mace/codegen/distribute/use_source.cc
+78
-0
mace/core/runtime/opencl/opencl_runtime.cc
mace/core/runtime/opencl/opencl_runtime.cc
+15
-76
mace/core/runtime/opencl/opencl_runtime.h
mace/core/runtime/opencl/opencl_runtime.h
+0
-1
mace/mace.bzl
mace/mace.bzl
+12
-0
mace/python/tools/binary_codegen.py
mace/python/tools/binary_codegen.py
+2
-3
mace/python/tools/encrypt_opencl_codegen.py
mace/python/tools/encrypt_opencl_codegen.py
+2
-3
mace/python/tools/opencl_codegen.py
mace/python/tools/opencl_codegen.py
+2
-3
mace/python/tools/str2vec_maps.cc.tmpl
mace/python/tools/str2vec_maps.cc.tmpl
+27
-0
mace/utils/tuner.h
mace/utils/tuner.h
+1
-1
tools/validate_gcn.sh
tools/validate_gcn.sh
+6
-4
未找到文件。
mace/codegen/BUILD
浏览文件 @
8d86da87
...
@@ -5,6 +5,8 @@ package(
...
@@ -5,6 +5,8 @@ package(
default_visibility
=
[
"//visibility:public"
],
default_visibility
=
[
"//visibility:public"
],
)
)
load
(
"//mace:mace.bzl"
,
"if_embed_binary_program"
,
"if_use_source_program"
)
cc_library
(
cc_library
(
name
=
"generated_models_lib"
,
name
=
"generated_models_lib"
,
srcs
=
glob
([
"models/*/*.cc"
]),
srcs
=
glob
([
"models/*/*.cc"
]),
...
@@ -13,12 +15,24 @@ cc_library(
...
@@ -13,12 +15,24 @@ cc_library(
deps
=
[
deps
=
[
"//mace/core"
,
"//mace/core"
,
"//mace/ops"
,
"//mace/ops"
,
"//mace/codegen:distribute_lib"
,
"//mace/codegen:version_lib"
,
"//mace/codegen:version_lib"
,
"//mace/codegen:generated_opencl_lib"
,
"//mace/codegen:generated_opencl_lib"
,
"//mace/codegen:generated_tuning_lib"
,
"//mace/codegen:generated_tuning_lib"
,
],
],
)
)
cc_library
(
name
=
"distribute_lib"
,
srcs
=
if_embed_binary_program
([
"distribute/use_binary.cc"
])
+
if_use_source_program
([
"distribute/use_source.cc"
]),
copts
=
[
"-std=c++11"
,
"-D_GLIBCXX_USE_C99_MATH_TR1"
,
"-Werror=return-type"
],
linkstatic
=
1
,
deps
=
[
"//mace/core"
,
],
)
cc_library
(
cc_library
(
name
=
"generated_opencl_lib"
,
name
=
"generated_opencl_lib"
,
srcs
=
glob
([
"opencl/*.cc"
]),
srcs
=
glob
([
"opencl/*.cc"
]),
...
...
mace/codegen/distribute/use_binary.cc
0 → 100644
浏览文件 @
8d86da87
#include <map>
#include <string>
#include <unordered_map>
#include <vector>
#include "mace/core/runtime/opencl/cl2_header.h"
namespace
mace
{
bool
GetSourceOrBinaryProgram
(
const
std
::
string
&
program_name
,
const
std
::
string
&
binary_file_name_prefix
,
cl
::
Context
&
context
,
cl
::
Device
&
device
,
cl
::
Program
*
program
,
bool
*
is_binary
)
{
extern
const
std
::
map
<
std
::
string
,
std
::
vector
<
unsigned
char
>>
kCompiledProgramMap
;
*
is_binary
=
true
;
auto
it_binary
=
kCompiledProgramMap
.
find
(
binary_file_name_prefix
);
if
(
it_binary
==
kCompiledProgramMap
.
end
())
{
return
false
;
}
*
program
=
cl
::
Program
(
context
,
{
device
},
{
it_binary
->
second
});
return
true
;
}
bool
GetTuningParams
(
const
char
*
path
,
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
unsigned
int
>>
*
param_table
)
{
extern
const
std
::
map
<
std
::
string
,
std
::
vector
<
unsigned
int
>>
kTuningParamsData
;
for
(
auto
it
=
kTuningParamsData
.
begin
();
it
!=
kTuningParamsData
.
end
();
++
it
)
{
param_table
->
emplace
(
it
->
first
,
std
::
vector
<
unsigned
int
>
(
it
->
second
.
begin
(),
it
->
second
.
end
()));
}
return
true
;
}
}
// namespace mace
mace/
python/tools/embed_code.cc.tmpl
→
mace/
codegen/distribute/use_source.cc
浏览文件 @
8d86da87
//
// Copyright (c) 2017 XiaoMi All rights reserved.
//
// This is a generated file, DO NOT EDIT
{% if mode == "read_tuning_config" %}
#include <fstream>
#include <fstream>
#include <map>
#include <string>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_map>
#include <vector>
#include "mace/core/runtime/opencl/cl2_header.h"
namespace
mace
{
namespace
mace
{
namespace
{
inline
void
DecryptOpenCLSource
(
const
std
::
vector
<
unsigned
char
>
&
src
,
std
::
vector
<
unsigned
char
>
*
dst
)
{
dst
->
reserve
(
src
.
size
());
// Keep consistent with encrypt in python tool
const
std
::
string
decrypt_lookup_table
=
"Xiaomi-AI-Platform-Mace"
;
size_t
lookup_table_size
=
decrypt_lookup_table
.
size
();
for
(
int
i
=
0
;
i
<
src
.
size
();
i
++
)
{
dst
->
push_back
(
src
[
i
]
^
decrypt_lookup_table
[
i
%
lookup_table_size
]);
}
}
}
// namespace
bool
GetSourceOrBinaryProgram
(
const
std
::
string
&
program_name
,
const
std
::
string
&
binary_file_name_prefix
,
cl
::
Context
&
context
,
cl
::
Device
&
device
,
cl
::
Program
*
program
,
bool
*
is_binary
)
{
extern
const
std
::
map
<
std
::
string
,
std
::
vector
<
unsigned
char
>>
kEncryptedProgramMap
;
*
is_binary
=
false
;
auto
it_source
=
kEncryptedProgramMap
.
find
(
program_name
);
if
(
it_source
==
kEncryptedProgramMap
.
end
())
{
return
false
;
}
cl
::
Program
::
Sources
sources
;
std
::
vector
<
unsigned
char
>
decrypt_source
;
DecryptOpenCLSource
(
it_source
->
second
,
&
decrypt_source
);
sources
.
push_back
(
std
::
string
(
decrypt_source
.
begin
(),
decrypt_source
.
end
()));
*
program
=
cl
::
Program
(
context
,
sources
);
return
true
;
}
bool
GetTuningParams
(
const
char
*
path
,
bool
GetTuningParams
(
const
char
*
path
,
std::unordered_map<std::string, std::vector<{{data_type}}
>> *param_table) {
std
::
unordered_map
<
std
::
string
,
std
::
vector
<
unsigned
int
>>
*
param_table
)
{
if
(
path
!=
nullptr
)
{
if
(
path
!=
nullptr
)
{
std
::
ifstream
ifs
(
path
,
std
::
ios
::
binary
|
std
::
ios
::
in
);
std
::
ifstream
ifs
(
path
,
std
::
ios
::
binary
|
std
::
ios
::
in
);
if
(
ifs
.
is_open
())
{
if
(
ifs
.
is_open
())
{
...
@@ -27,10 +60,10 @@ bool GetTuningParams(const char *path,
...
@@ -27,10 +60,10 @@ bool GetTuningParams(const char *path,
ifs
.
read
(
&
key
[
0
],
key_size
);
ifs
.
read
(
&
key
[
0
],
key_size
);
ifs
.
read
(
reinterpret_cast
<
char
*>
(
&
params_size
),
sizeof
(
params_size
));
ifs
.
read
(
reinterpret_cast
<
char
*>
(
&
params_size
),
sizeof
(
params_size
));
params_count = params_size / sizeof(
{{data_type}}
);
params_count
=
params_size
/
sizeof
(
unsigned
int
);
std::vector<
{{data_type}}
> params(params_count);
std
::
vector
<
unsigned
int
>
params
(
params_count
);
for
(
int
i
=
0
;
i
<
params_count
;
++
i
)
{
for
(
int
i
=
0
;
i
<
params_count
;
++
i
)
{
ifs.read(reinterpret_cast<char *>(¶ms[i]), sizeof(
{{data_type}}
));
ifs
.
read
(
reinterpret_cast
<
char
*>
(
&
params
[
i
]),
sizeof
(
unsigned
int
));
}
}
param_table
->
emplace
(
key
,
params
);
param_table
->
emplace
(
key
,
params
);
}
}
...
@@ -41,71 +74,5 @@ bool GetTuningParams(const char *path,
...
@@ -41,71 +74,5 @@ bool GetTuningParams(const char *path,
}
}
return
true
;
return
true
;
}
}
} // namespace
{% else %}
#include <map>
#include <string>
#include <vector>
{% if mode == "tuning_binary" %}
#include <unordered_map>
{% endif %}
namespace mace {
extern const std::map<std::string, std::vector<{{data_type}}>> {{variable_name}}=
{
{% for key, value in maps.iteritems() %}
{
"{{key}}",
{
{%- for ele in value -%}
{{ele}},
{%- endfor -%}
}
}, // {{key}}
{% endfor %}
};
{% if mode == "cl_encrypt" %}
bool GetOpenCLProgram(const std::string &program_name,
const std::string &binary_file_name_prefix,
std::vector<unsigned char> *program_vec,
bool *is_binary) {
*is_binary = false;
auto it_source = {{variable_name}}.find(program_name);
if (it_source == {{variable_name}}.end()) {
return false;
}
*program_vec = it_source->second;
return true;
}
{% elif mode == "cl_binary" %}
bool GetOpenCLProgram(const std::string &program_name,
const std::string &binary_file_name_prefix,
std::vector<unsigned char> *program_vec,
bool *is_binary) {
*is_binary = true;
auto it_source = {{variable_name}}.find(binary_file_name_prefix);
if (it_source == {{variable_name}}.end()) {
return false;
}
*program_vec = it_source->second;
return true;
}
{% elif mode == "tuning_binary" %}
bool GetTuningParams(const char *path,
std::unordered_map<std::string, std::vector<{{data_type}}>> *param_table) {
for (auto it = kTuningParamsData.begin(); it != kTuningParamsData.end(); ++it) {
param_table->emplace(it->first, std::vector<{{data_type}}>(it->second.begin(), it->second.end()));
}
return true;
}
{% endif %}
} // namespace
{% endif %}
}
// namespace mace
mace/core/runtime/opencl/opencl_runtime.cc
浏览文件 @
8d86da87
...
@@ -16,47 +16,6 @@
...
@@ -16,47 +16,6 @@
namespace
mace
{
namespace
mace
{
namespace
{
namespace
{
bool
ReadFile
(
const
std
::
string
&
filename
,
bool
binary
,
std
::
vector
<
unsigned
char
>
*
content_ptr
)
{
MACE_CHECK_NOTNULL
(
content_ptr
);
std
::
ios_base
::
openmode
mode
=
std
::
ios
::
in
;
if
(
binary
)
{
mode
|=
std
::
ios
::
binary
;
}
std
::
ifstream
ifs
(
filename
,
mode
);
// Stop eating new lines and whitespace
ifs
.
unsetf
(
std
::
ios
::
skipws
);
if
(
!
ifs
.
is_open
())
{
LOG
(
ERROR
)
<<
"Failed to open file "
<<
filename
;
return
false
;
}
ifs
.
seekg
(
0
,
std
::
ios
::
end
);
const
size_t
filesize
=
ifs
.
tellg
();
if
(
filesize
>
10
*
1024
*
1024
)
{
LOG
(
ERROR
)
<<
"Filesize overflow 10MB"
;
return
false
;
}
content_ptr
->
reserve
(
filesize
);
ifs
.
seekg
(
0
,
std
::
ios
::
beg
);
content_ptr
->
insert
(
content_ptr
->
begin
(),
std
::
istreambuf_iterator
<
char
>
(
ifs
),
std
::
istreambuf_iterator
<
char
>
());
if
(
ifs
.
fail
())
{
LOG
(
ERROR
)
<<
"Failed to read from file "
<<
filename
;
return
false
;
}
ifs
.
close
();
return
true
;
}
bool
WriteFile
(
const
std
::
string
&
filename
,
bool
WriteFile
(
const
std
::
string
&
filename
,
bool
binary
,
bool
binary
,
const
std
::
vector
<
unsigned
char
>
&
content
)
{
const
std
::
vector
<
unsigned
char
>
&
content
)
{
...
@@ -174,24 +133,13 @@ std::string OpenCLRuntime::GenerateCLBinaryFilenamePrefix(
...
@@ -174,24 +133,13 @@ std::string OpenCLRuntime::GenerateCLBinaryFilenamePrefix(
return
filename_prefix
;
return
filename_prefix
;
}
}
extern
bool
GetOpenCLProgram
(
extern
bool
GetSourceOrBinaryProgram
(
const
std
::
string
&
program_name
,
const
std
::
string
&
program_name
,
const
std
::
string
&
binary_file_name_prefix
,
const
std
::
string
&
binary_file_name_prefix
,
std
::
vector
<
unsigned
char
>
*
program_vec
,
cl
::
Context
&
context
,
cl
::
Device
&
device
,
cl
::
Program
*
program
,
bool
*
is_opencl_binary
);
bool
*
is_opencl_binary
);
const
std
::
vector
<
unsigned
char
>
OpenCLRuntime
::
DecryptOpenCLSource
(
const
std
::
vector
<
unsigned
char
>
&
src
)
{
std
::
vector
<
unsigned
char
>
res
;
res
.
reserve
(
src
.
size
());
std
::
string
decrypt_lookup_table
=
"Xiaomi-AI-Platform-Mace"
;
size_t
lookup_table_size
=
decrypt_lookup_table
.
size
();
for
(
int
i
=
0
;
i
<
src
.
size
();
i
++
)
{
res
.
push_back
(
src
[
i
]
^
decrypt_lookup_table
[
i
%
lookup_table_size
]);
}
return
res
;
}
void
OpenCLRuntime
::
BuildProgram
(
const
std
::
string
&
program_name
,
void
OpenCLRuntime
::
BuildProgram
(
const
std
::
string
&
program_name
,
const
std
::
string
&
binary_file_name_prefix
,
const
std
::
string
&
binary_file_name_prefix
,
const
std
::
string
&
build_options
,
const
std
::
string
&
build_options
,
...
@@ -200,27 +148,18 @@ void OpenCLRuntime::BuildProgram(const std::string &program_name,
...
@@ -200,27 +148,18 @@ void OpenCLRuntime::BuildProgram(const std::string &program_name,
bool
is_opencl_binary
=
false
;
bool
is_opencl_binary
=
false
;
std
::
vector
<
unsigned
char
>
program_vec
;
std
::
vector
<
unsigned
char
>
program_vec
;
const
bool
is_success
=
GetOpenCL
Program
(
program_name
,
const
bool
found
=
GetSourceOrBinary
Program
(
program_name
,
binary_file_name_prefix
,
binary_file_name_prefix
,
&
program_vec
,
context
(),
device
(),
program
,
&
is_opencl_binary
);
&
is_opencl_binary
);
MACE_CHECK
(
is_success
,
"Failed in GetOpenCLProgram!"
);
MACE_CHECK
(
found
,
"Program not found source: "
,
program_name
,
", or binary: "
,
if
(
is_opencl_binary
)
{
binary_file_name_prefix
);
*
program
=
cl
::
Program
(
this
->
context
(),
{
device
()},
{
program_vec
});
VLOG
(
1
)
<<
"Use opencl binaries"
;
}
else
{
cl
::
Program
::
Sources
sources
;
const
std
::
vector
<
unsigned
char
>
decrypt_source
=
DecryptOpenCLSource
(
program_vec
);
sources
.
push_back
(
std
::
string
(
decrypt_source
.
begin
(),
decrypt_source
.
end
()));
*
program
=
cl
::
Program
(
this
->
context
(),
sources
);
VLOG
(
1
)
<<
"Use opencl sources"
;
}
// Build program
// Build program
std
::
string
build_options_str
=
std
::
string
build_options_str
=
build_options
+
" -Werror -cl-mad-enable -cl-fast-relaxed-math -I"
+
build_options
+
" -Werror -cl-mad-enable -cl-fast-relaxed-math"
;
kernel_path_
;
// TODO(heliangliang) -cl-unsafe-math-optimizations -cl-fast-relaxed-math
// TODO(heliangliang) -cl-unsafe-math-optimizations -cl-fast-relaxed-math
cl_int
ret
=
program
->
build
({
device
()},
build_options_str
.
c_str
());
cl_int
ret
=
program
->
build
({
device
()},
build_options_str
.
c_str
());
if
(
ret
!=
CL_SUCCESS
)
{
if
(
ret
!=
CL_SUCCESS
)
{
...
...
mace/core/runtime/opencl/opencl_runtime.h
浏览文件 @
8d86da87
...
@@ -55,7 +55,6 @@ class OpenCLRuntime {
...
@@ -55,7 +55,6 @@ class OpenCLRuntime {
const
std
::
string
&
build_options
,
const
std
::
string
&
build_options
,
cl
::
Program
*
program
);
cl
::
Program
*
program
);
std
::
string
GenerateCLBinaryFilenamePrefix
(
const
std
::
string
&
filename_msg
);
std
::
string
GenerateCLBinaryFilenamePrefix
(
const
std
::
string
&
filename_msg
);
const
std
::
vector
<
unsigned
char
>
DecryptOpenCLSource
(
const
std
::
vector
<
unsigned
char
>
&
src
);
private:
private:
// All OpenCL object must be a pointer and manually deleted before unloading
// All OpenCL object must be a pointer and manually deleted before unloading
...
...
mace/mace.bzl
浏览文件 @
8d86da87
...
@@ -30,6 +30,18 @@ def if_profiling_enabled(a):
...
@@ -30,6 +30,18 @@ def if_profiling_enabled(a):
"//conditions:default"
:
[],
"//conditions:default"
:
[],
})
})
def
if_embed_binary_program
(
a
):
return
select
({
"//mace:embed_binary_program"
:
a
,
"//conditions:default"
:
[],
})
def
if_use_source_program
(
a
):
return
select
({
"//mace:embed_binary_program"
:
[],
"//conditions:default"
:
a
,
})
def
if_enable_neon
(
a
):
def
if_enable_neon
(
a
):
return
select
({
return
select
({
"//mace:enable_neon"
:
a
,
"//mace:enable_neon"
:
a
,
...
...
mace/python/tools/binary_codegen.py
浏览文件 @
8d86da87
...
@@ -38,11 +38,10 @@ def generate_cpp_source():
...
@@ -38,11 +38,10 @@ def generate_cpp_source():
idx
+=
params_size
idx
+=
params_size
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
sys
.
path
[
0
]))
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
sys
.
path
[
0
]))
return
env
.
get_template
(
'
embed_code
.cc.tmpl'
).
render
(
return
env
.
get_template
(
'
str2vec_maps
.cc.tmpl'
).
render
(
maps
=
data_map
,
maps
=
data_map
,
data_type
=
'unsigned int'
,
data_type
=
'unsigned int'
,
variable_name
=
FLAGS
.
variable_name
,
variable_name
=
FLAGS
.
variable_name
mode
=
"tuning_binary"
)
)
def
main
(
unused_args
):
def
main
(
unused_args
):
...
...
mace/python/tools/encrypt_opencl_codegen.py
浏览文件 @
8d86da87
...
@@ -45,11 +45,10 @@ def main(unused_args):
...
@@ -45,11 +45,10 @@ def main(unused_args):
encrypted_code_maps
[
file_name
[:
-
3
]]
=
encrypted_code_arr
encrypted_code_maps
[
file_name
[:
-
3
]]
=
encrypted_code_arr
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
sys
.
path
[
0
]))
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
sys
.
path
[
0
]))
cpp_cl_encrypted_kernel
=
env
.
get_template
(
'
embed_code
.cc.tmpl'
).
render
(
cpp_cl_encrypted_kernel
=
env
.
get_template
(
'
str2vec_maps
.cc.tmpl'
).
render
(
maps
=
encrypted_code_maps
,
maps
=
encrypted_code_maps
,
data_type
=
'unsigned char'
,
data_type
=
'unsigned char'
,
variable_name
=
'kEncryptedProgramMap'
,
variable_name
=
'kEncryptedProgramMap'
)
mode
=
'cl_encrypt'
)
if
os
.
path
.
isfile
(
FLAGS
.
output_path
):
if
os
.
path
.
isfile
(
FLAGS
.
output_path
):
os
.
remove
(
FLAGS
.
output_path
)
os
.
remove
(
FLAGS
.
output_path
)
...
...
mace/python/tools/opencl_codegen.py
浏览文件 @
8d86da87
...
@@ -27,11 +27,10 @@ def generate_cpp_source():
...
@@ -27,11 +27,10 @@ def generate_cpp_source():
maps
[
file_name
[:
-
4
]].
append
(
hex
(
ele
))
maps
[
file_name
[:
-
4
]].
append
(
hex
(
ele
))
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
sys
.
path
[
0
]))
env
=
jinja2
.
Environment
(
loader
=
jinja2
.
FileSystemLoader
(
sys
.
path
[
0
]))
return
env
.
get_template
(
'
embed_code
.cc.tmpl'
).
render
(
return
env
.
get_template
(
'
str2vec_maps
.cc.tmpl'
).
render
(
maps
=
maps
,
maps
=
maps
,
data_type
=
'unsigned char'
,
data_type
=
'unsigned char'
,
variable_name
=
'kCompiledProgramMap'
,
variable_name
=
'kCompiledProgramMap'
mode
=
"cl_binary"
)
)
...
...
mace/python/tools/str2vec_maps.cc.tmpl
0 → 100644
浏览文件 @
8d86da87
//
// Copyright (c) 2017 XiaoMi All rights reserved.
//
// This is a generated file, DO NOT EDIT
#include <map>
#include <string>
#include <vector>
namespace mace {
extern const std::map<std::string, std::vector<{{data_type}}>> {{variable_name}}=
{
{% for key, value in maps.iteritems() %}
{
"{{key}}",
{
{%- for ele in value -%}
{{ele}},
{%- endfor -%}
}
}, // {{key}}
{% endfor %}
};
} // namespace
mace/utils/tuner.h
浏览文件 @
8d86da87
...
@@ -104,7 +104,7 @@ class Tuner {
...
@@ -104,7 +104,7 @@ class Tuner {
inline
void
ReadRunParamters
()
{
inline
void
ReadRunParamters
()
{
bool
success
=
GetTuningParams
(
path_
,
&
param_table_
);
bool
success
=
GetTuningParams
(
path_
,
&
param_table_
);
if
(
!
success
)
{
if
(
!
success
)
{
LOG
(
WARNING
)
<<
"
Read
run parameter failed."
;
LOG
(
WARNING
)
<<
"
Get
run parameter failed."
;
}
}
}
}
...
...
tools/validate_gcn.sh
浏览文件 @
8d86da87
...
@@ -35,6 +35,9 @@ VERSION_SOURCE_PATH=${CODEGEN_DIR}/version
...
@@ -35,6 +35,9 @@ VERSION_SOURCE_PATH=${CODEGEN_DIR}/version
build_and_run
()
build_and_run
()
{
{
EMBED_OPENCL_BINARY
=
$1
EMBED_OPENCL_BINARY
=
$1
if
[
"
$EMBED_OPENCL_BINARY
"
=
true
]
;
then
EMBED_OPENCL_BINARY_BUILD_FLAGS
=
"--define embed_binary_program=true"
fi
bazel build
-c
opt
--strip
always mace/examples:mace_run
\
bazel build
-c
opt
--strip
always mace/examples:mace_run
\
--crosstool_top
=
//external:android/crosstool
\
--crosstool_top
=
//external:android/crosstool
\
...
@@ -44,6 +47,9 @@ build_and_run()
...
@@ -44,6 +47,9 @@ build_and_run()
--copt
=
-DMACE_MODEL_FUNCTION
=
Create
${
MODEL_TAG
}
--copt
=
-DMACE_MODEL_FUNCTION
=
Create
${
MODEL_TAG
}
adb shell
"mkdir -p
${
PHONE_DATA_DIR
}
"
adb shell
"mkdir -p
${
PHONE_DATA_DIR
}
"
if
[
"
$EMBED_OPENCL_BINARY
"
=
false
]
;
then
adb shell
"mkdir -p
${
KERNEL_DIR
}
"
fi
adb push
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
${
PHONE_DATA_DIR
}
adb push
${
MODEL_DIR
}
/
${
INPUT_FILE_NAME
}
${
PHONE_DATA_DIR
}
adb push bazel-bin/mace/examples/mace_run
${
PHONE_DATA_DIR
}
adb push bazel-bin/mace/examples/mace_run
${
PHONE_DATA_DIR
}
...
@@ -99,13 +105,9 @@ bash mace/tools/git/gen_version_source.sh ${VERSION_SOURCE_PATH}/version.cc
...
@@ -99,13 +105,9 @@ bash mace/tools/git/gen_version_source.sh ${VERSION_SOURCE_PATH}/version.cc
echo
"Step 4: Generate encrypted opencl source and read tuning method"
echo
"Step 4: Generate encrypted opencl source and read tuning method"
rm
-rf
${
CL_CODEGEN_DIR
}
rm
-rf
${
CL_CODEGEN_DIR
}
rm
-rf
${
TUNING_CODEGEN_DIR
}
mkdir
-p
${
CL_CODEGEN_DIR
}
mkdir
-p
${
CL_CODEGEN_DIR
}
mkdir
-p
${
TUNING_CODEGEN_DIR
}
python mace/python/tools/encrypt_opencl_codegen.py
\
python mace/python/tools/encrypt_opencl_codegen.py
\
--cl_kernel_dir
=
./mace/kernels/opencl/cl/
--output_path
=
${
CL_CODEGEN_DIR
}
/opencl_encrypt_program.cc
--cl_kernel_dir
=
./mace/kernels/opencl/cl/
--output_path
=
${
CL_CODEGEN_DIR
}
/opencl_encrypt_program.cc
python mace/python/tools/read_tuning_codegen.py
\
--output_path
=
${
TUNING_CODEGEN_DIR
}
/read_tuning_params.cc
echo
"Step 5: Run model on the phone with files"
echo
"Step 5: Run model on the phone with files"
build_and_run
false
build_and_run
false
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录