Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
PaddleDetection
提交
f116bb9e
P
PaddleDetection
项目概览
PaddlePaddle
/
PaddleDetection
大约 1 年 前同步成功
通知
695
Star
11112
Fork
2696
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
184
列表
看板
标记
里程碑
合并请求
40
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
PaddleDetection
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
184
Issue
184
列表
看板
标记
里程碑
合并请求
40
合并请求
40
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f116bb9e
编写于
6月 17, 2019
作者:
T
tensor-tang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'tangjian/lite/cmake' into 'incubate/lite'
Tangjian/lite/cmake See merge request inference/paddlelite!19
上级
c62ae03b
16c33ef4
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
143 addition
and
93 deletion
+143
-93
CMakeLists.txt
CMakeLists.txt
+18
-7
cmake/cross_compiling/android.cmake
cmake/cross_compiling/android.cmake
+11
-12
cmake/cross_compiling/armlinux.cmake
cmake/cross_compiling/armlinux.cmake
+12
-5
paddle/fluid/lite/api/cxx_api_bin.cc
paddle/fluid/lite/api/cxx_api_bin.cc
+3
-3
paddle/fluid/lite/core/context.cc
paddle/fluid/lite/core/context.cc
+22
-17
paddle/fluid/lite/kernels/arm/conv_compute.cc
paddle/fluid/lite/kernels/arm/conv_compute.cc
+2
-0
paddle/fluid/lite/kernels/arm/fc_compute.cc
paddle/fluid/lite/kernels/arm/fc_compute.cc
+3
-0
paddle/fluid/lite/kernels/arm/mul_compute.cc
paddle/fluid/lite/kernels/arm/mul_compute.cc
+2
-1
paddle/fluid/lite/kernels/arm/pool_compute.cc
paddle/fluid/lite/kernels/arm/pool_compute.cc
+5
-0
paddle/fluid/lite/kernels/arm/pool_compute.h
paddle/fluid/lite/kernels/arm/pool_compute.h
+1
-0
paddle/fluid/lite/tools/build.sh
paddle/fluid/lite/tools/build.sh
+55
-46
paddle/fluid/lite/tools/mobile_readme.md
paddle/fluid/lite/tools/mobile_readme.md
+9
-2
未找到文件。
CMakeLists.txt
浏览文件 @
f116bb9e
...
@@ -22,6 +22,7 @@ include(system)
...
@@ -22,6 +22,7 @@ include(system)
if
(
LITE_WITH_LIGHT_WEIGHT_FRAMEWORK
)
if
(
LITE_WITH_LIGHT_WEIGHT_FRAMEWORK
)
cmake_minimum_required
(
VERSION 3.10
)
cmake_minimum_required
(
VERSION 3.10
)
# TODO(TJ): make as function check_default
# TODO(TJ): make as function check_default
# check os
if
(
NOT DEFINED ARM_TARGET_OS
)
if
(
NOT DEFINED ARM_TARGET_OS
)
set
(
ARM_TARGET_OS
"android"
CACHE STRING
"Choose ARM Target OS"
)
set
(
ARM_TARGET_OS
"android"
CACHE STRING
"Choose ARM Target OS"
)
endif
()
endif
()
...
@@ -31,19 +32,17 @@ if(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
...
@@ -31,19 +32,17 @@ if(LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
message
(
FATAL_ERROR
"ARM_TARGET_OS must be in one of
${
ARM_TARGET_OS_LIST
}
"
)
message
(
FATAL_ERROR
"ARM_TARGET_OS must be in one of
${
ARM_TARGET_OS_LIST
}
"
)
endif
()
endif
()
# check arch abi
if
(
NOT DEFINED ARM_TARGET_ARCH_ABI
)
if
(
NOT DEFINED ARM_TARGET_ARCH_ABI
)
set
(
ARM_TARGET_ARCH_ABI
"arm
64-v8a
"
CACHE STRING
"Choose ARM Target ARCH ABI"
)
set
(
ARM_TARGET_ARCH_ABI
"arm
v8
"
CACHE STRING
"Choose ARM Target ARCH ABI"
)
endif
()
endif
()
set
(
ARM_TARGET_ARCH_ABI_LIST
"arm
64-v8a"
"armeabi-v7a"
"armeabi-v7a-softfp"
"armeabi-v7a-hf
"
)
set
(
ARM_TARGET_ARCH_ABI_LIST
"arm
v8"
"armv7"
"armv7hf"
"arm64-v8a"
"armeabi-v7a
"
)
set_property
(
CACHE ARM_TARGET_ARCH_ABI PROPERTY STRINGS
${
ARM_TARGET_ARCH_ABI_LIST
}
)
set_property
(
CACHE ARM_TARGET_ARCH_ABI PROPERTY STRINGS
${
ARM_TARGET_ARCH_ABI_LIST
}
)
if
(
NOT ARM_TARGET_ARCH_ABI IN_LIST ARM_TARGET_ARCH_ABI_LIST
)
if
(
NOT ARM_TARGET_ARCH_ABI IN_LIST ARM_TARGET_ARCH_ABI_LIST
)
message
(
FATAL_ERROR
"ARM_TARGET_ARCH_ABI must be in one of
${
ARM_TARGET_ARCH_ABI_LIST
}
"
)
message
(
FATAL_ERROR
"ARM_TARGET_ARCH_ABI must be in one of
${
ARM_TARGET_ARCH_ABI_LIST
}
"
)
endif
()
endif
()
if
(
NOT DEFINED TARGET_ARCH_ABI
)
message
(
STATUS
"Lite ARM Compile
${
ARM_TARGET_OS
}
with
${
ARM_TARGET_ARCH_ABI
}
"
)
set
(
ARCH_ABI
"arm64-v8a"
CACHE STRING
"Choose android platform"
)
endif
()
include
(
cross_compiling/host
)
include
(
cross_compiling/host
)
include
(
cross_compiling/armlinux
)
include
(
cross_compiling/armlinux
)
include
(
cross_compiling/android
)
include
(
cross_compiling/android
)
...
@@ -171,8 +170,20 @@ if (WITH_LITE AND LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
...
@@ -171,8 +170,20 @@ if (WITH_LITE AND LITE_WITH_LIGHT_WEIGHT_FRAMEWORK)
include
(
generic
)
# simplify cmake module
include
(
generic
)
# simplify cmake module
include
(
configure
)
# add paddle env configuration
include
(
configure
)
# add paddle env configuration
add_definitions
(
-std=c++11
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
-std=c++11"
)
find_package
(
OpenMP REQUIRED
)
if
(
OPENMP_FOUND OR OpenMP_CXX_FOUND
)
add_definitions
(
-DARM_WITH_OMP
)
set
(
CMAKE_C_FLAGS
"
${
CMAKE_C_FLAGS
}
${
OpenMP_C_FLAGS
}
"
)
set
(
CMAKE_CXX_FLAGS
"
${
CMAKE_CXX_FLAGS
}
${
OpenMP_CXX_FLAGS
}
"
)
message
(
STATUS
"Found OpenMP
${
OpenMP_VERSION
}
${
OpenMP_CXX_VERSION
}
"
)
message
(
STATUS
" |-- OpenMP C flags:
${
OpenMP_C_FLAGS
}
"
)
message
(
STATUS
" |-- OpenMP CXX flags:
${
OpenMP_CXX_FLAGS
}
"
)
message
(
STATUS
" |-- OpenMP OpenMP_CXX_LIB_NAMES:
${
OpenMP_CXX_LIB_NAMES
}
"
)
message
(
STATUS
" `-- OpenMP OpenMP_CXX_LIBRARIES:
${
OpenMP_CXX_LIBRARIES
}
"
)
else
()
message
(
FATAL_ERROR
"Could not found openmp !"
)
endif
()
add_subdirectory
(
paddle
)
add_subdirectory
(
paddle
)
return
()
return
()
...
...
cmake/cross_compiling/android.cmake
浏览文件 @
f116bb9e
...
@@ -26,7 +26,6 @@ if(NOT DEFINED ANDROID_NDK)
...
@@ -26,7 +26,6 @@ if(NOT DEFINED ANDROID_NDK)
endif
()
endif
()
endif
()
endif
()
if
(
NOT DEFINED ANDROID_API_LEVEL
)
if
(
NOT DEFINED ANDROID_API_LEVEL
)
set
(
ANDROID_API_LEVEL
"22"
)
set
(
ANDROID_API_LEVEL
"22"
)
endif
()
endif
()
...
@@ -35,19 +34,26 @@ if(NOT DEFINED ANDROID_STL_TYPE)
...
@@ -35,19 +34,26 @@ if(NOT DEFINED ANDROID_STL_TYPE)
set
(
ANDROID_STL_TYPE
"c++_static"
CACHE STRING
"stl type"
)
set
(
ANDROID_STL_TYPE
"c++_static"
CACHE STRING
"stl type"
)
endif
()
endif
()
# TODO(TJ): enable me
if
(
ARM_TARGET_ARCH_ABI STREQUAL
"armv7hf"
)
if
(
ARM_TARGET_ARCH_ABI STREQUAL
"armeabi-v7a-hf"
)
message
(
FATAL_ERROR
"ANDROID does not support hardfp on v7 use armv7 instead."
)
message
(
FATAL_ERROR
"Not supported building android armeabi-v7a-hf yet"
)
endif
()
endif
()
set
(
ANDROID_ARCH_ABI
${
ARM_TARGET_ARCH_ABI
}
CACHE STRING
"Choose Android Arch ABI"
)
set
(
ANDROID_ARCH_ABI
${
ARM_TARGET_ARCH_ABI
}
CACHE STRING
"Choose Android Arch ABI"
)
if
(
ARM_TARGET_ARCH_ABI STREQUAL
"armv8"
)
set
(
ANDROID_ARCH_ABI
"arm64-v8a"
)
endif
()
if
(
ARM_TARGET_ARCH_ABI STREQUAL
"armv7"
)
set
(
ANDROID_ARCH_ABI
"armeabi-v7a"
)
endif
()
if
(
ANDROID_ARCH_ABI STREQUAL
"armeabi-v7a-softfp"
)
if
(
ANDROID_ARCH_ABI STREQUAL
"armeabi-v7a-softfp"
)
set
(
ANDROID_ARCH_ABI
"armeabi-v7a"
)
set
(
ANDROID_ARCH_ABI
"armeabi-v7a"
)
endif
()
endif
()
set
(
ANDROID_ARCH_ABI_LIST
"arm64-v8a"
"armeabi-v7a"
"armeabi-v6"
"armeabi"
set
(
ANDROID_ARCH_ABI_LIST
"arm64-v8a"
"armeabi-v7a"
"armeabi-v6"
"armeabi"
"mips"
"mips64"
"x86"
"x86_64"
"armeabi-v7a-hf"
)
"mips"
"mips64"
"x86"
"x86_64"
)
set_property
(
CACHE ANDROID_ARCH_ABI PROPERTY STRINGS
${
ANDROID_ARCH_ABI_LIST
}
)
set_property
(
CACHE ANDROID_ARCH_ABI PROPERTY STRINGS
${
ANDROID_ARCH_ABI_LIST
}
)
if
(
NOT ANDROID_ARCH_ABI IN_LIST ANDROID_ARCH_ABI_LIST
)
if
(
NOT ANDROID_ARCH_ABI IN_LIST ANDROID_ARCH_ABI_LIST
)
message
(
FATAL_ERROR
"ANDROID_ARCH_ABI must be in one of
${
ANDROID_ARCH_ABI_LIST
}
"
)
message
(
FATAL_ERROR
"ANDROID_ARCH_ABI must be in one of
${
ANDROID_ARCH_ABI_LIST
}
"
)
...
@@ -59,13 +65,6 @@ if(ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
...
@@ -59,13 +65,6 @@ if(ANDROID_ARCH_ABI STREQUAL "armeabi-v7a")
message
(
STATUS
"NEON is enabled on arm-v7a with softfp"
)
message
(
STATUS
"NEON is enabled on arm-v7a with softfp"
)
endif
()
endif
()
if
(
ANDROID_ARCH_ABI STREQUAL
"armeabi-v7a-hf"
)
set
(
ANDROID_ARCH_ABI
"armeabi-v7a"
)
set
(
CMAKE_CXX_FLAGS
"-std=c++11 -march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4
${
CMAKE_CXX_FLAGS
}
"
)
set
(
CMAKE_C_FLAGS
"-march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4
${
CMAKE_C_FLAGS
}
"
)
message
(
STATUS
"NEON is enabled on arm-v7a with hard float"
)
endif
()
set
(
ANDROID_STL_TYPE_LITS
"gnustl_static"
"c++_static"
)
set
(
ANDROID_STL_TYPE_LITS
"gnustl_static"
"c++_static"
)
set_property
(
CACHE ANDROID_STL_TYPE PROPERTY STRINGS
${
ANDROID_STL_TYPE_LITS
}
)
set_property
(
CACHE ANDROID_STL_TYPE PROPERTY STRINGS
${
ANDROID_STL_TYPE_LITS
}
)
if
(
NOT ANDROID_STL_TYPE IN_LIST ANDROID_STL_TYPE_LITS
)
if
(
NOT ANDROID_STL_TYPE IN_LIST ANDROID_STL_TYPE_LITS
)
...
...
cmake/cross_compiling/armlinux.cmake
浏览文件 @
f116bb9e
...
@@ -20,7 +20,15 @@ set(ARMLINUX TRUE)
...
@@ -20,7 +20,15 @@ set(ARMLINUX TRUE)
add_definitions
(
-DLITE_WITH_LINUX
)
add_definitions
(
-DLITE_WITH_LINUX
)
set
(
CMAKE_SYSTEM_NAME Linux
)
set
(
CMAKE_SYSTEM_NAME Linux
)
if
(
ARM_TARGET_ARCH_ABI STREQUAL
"arm64-v8a"
)
set
(
ARMLINUX_ARCH_ABI
${
ARM_TARGET_ARCH_ABI
}
CACHE STRING
"Choose Android Arch ABI"
)
set
(
ARMLINUX_ARCH_ABI_LIST
"armv8"
"armv7"
"armv7hf"
)
set_property
(
CACHE ARMLINUX_ARCH_ABI PROPERTY STRINGS
${
ARMLINUX_ARCH_ABI_LIST
}
)
if
(
NOT ARMLINUX_ARCH_ABI IN_LIST ARMLINUX_ARCH_ABI_LIST
)
message
(
FATAL_ERROR
"ARMLINUX_ARCH_ABI(
${
ARMLINUX_ARCH_ABI
}
) must be in one of
${
ARMLINUX_ARCH_ABI_LIST
}
"
)
endif
()
if
(
ARMLINUX_ARCH_ABI STREQUAL
"armv8"
)
set
(
CMAKE_SYSTEM_PROCESSOR aarch64
)
set
(
CMAKE_SYSTEM_PROCESSOR aarch64
)
set
(
CMAKE_C_COMPILER
"aarch64-linux-gnu-gcc"
)
set
(
CMAKE_C_COMPILER
"aarch64-linux-gnu-gcc"
)
set
(
CMAKE_CXX_COMPILER
"aarch64-linux-gnu-g++"
)
set
(
CMAKE_CXX_COMPILER
"aarch64-linux-gnu-g++"
)
...
@@ -30,13 +38,12 @@ if(ARM_TARGET_ARCH_ABI STREQUAL "arm64-v8a")
...
@@ -30,13 +38,12 @@ if(ARM_TARGET_ARCH_ABI STREQUAL "arm64-v8a")
message
(
STATUS
"NEON is enabled on arm64-v8a"
)
message
(
STATUS
"NEON is enabled on arm64-v8a"
)
endif
()
endif
()
if
(
ARM_TARGET_ARCH_ABI STREQUAL
"armeabi-v7a"
if
(
ARMLINUX_ARCH_ABI STREQUAL
"armv7"
OR ARMLINUX_ARCH_ABI STREQUAL
"armv7hf"
)
OR ARM_TARGET_ARCH_ABI STREQUAL
"armeabi-v7a-hf"
)
message
(
FATAL_ERROR
"Not supported building arm linux arm-v7 yet"
)
message
(
FATAL_ERROR
"Not supported building arm linux arm-v7 yet"
)
endif
()
endif
()
# TODO(TJ): make sure v7 works
# TODO(TJ): make sure v7 works
if
(
ARM
_TARGET_ARCH_ABI STREQUAL
"armeabi-v7a
"
)
if
(
ARM
LINUX_ARCH_ABI STREQUAL
"armv7
"
)
set
(
CMAKE_SYSTEM_PROCESSOR arm
)
set
(
CMAKE_SYSTEM_PROCESSOR arm
)
set
(
CMAKE_C_COMPILER
"arm-linux-gnueabi-gcc"
)
set
(
CMAKE_C_COMPILER
"arm-linux-gnueabi-gcc"
)
set
(
CMAKE_CXX_COMPILER
"arm-linux-gnueabi-g++"
)
set
(
CMAKE_CXX_COMPILER
"arm-linux-gnueabi-g++"
)
...
@@ -46,7 +53,7 @@ if(ARM_TARGET_ARCH_ABI STREQUAL "armeabi-v7a")
...
@@ -46,7 +53,7 @@ if(ARM_TARGET_ARCH_ABI STREQUAL "armeabi-v7a")
message
(
STATUS
"NEON is enabled on arm-v7a with softfp"
)
message
(
STATUS
"NEON is enabled on arm-v7a with softfp"
)
endif
()
endif
()
if
(
ARM
_TARGET_ARCH_ABI STREQUAL
"armeabi-v7a-
hf"
)
if
(
ARM
LINUX_ARCH_ABI STREQUAL
"armv7
hf"
)
set
(
CMAKE_SYSTEM_PROCESSOR arm
)
set
(
CMAKE_SYSTEM_PROCESSOR arm
)
set
(
CMAKE_C_COMPILER
"arm-linux-gnueabihf-gcc"
)
set
(
CMAKE_C_COMPILER
"arm-linux-gnueabihf-gcc"
)
set
(
CMAKE_CXX_COMPILER
"arm-linux-gnueabihf-g++"
)
set
(
CMAKE_CXX_COMPILER
"arm-linux-gnueabihf-g++"
)
...
...
paddle/fluid/lite/api/cxx_api_bin.cc
浏览文件 @
f116bb9e
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
// limitations under the License.
// limitations under the License.
#include "paddle/fluid/lite/api/cxx_api.h"
#include "paddle/fluid/lite/api/cxx_api.h"
#include <chrono>
#include <chrono>
// NOLINT
#include "paddle/fluid/lite/core/mir/passes.h"
#include "paddle/fluid/lite/core/mir/passes.h"
#include "paddle/fluid/lite/core/op_registry.h"
#include "paddle/fluid/lite/core/op_registry.h"
namespace
paddle
{
namespace
paddle
{
...
@@ -66,8 +66,8 @@ void Run(const char* model_dir, int repeat) {
...
@@ -66,8 +66,8 @@ void Run(const char* model_dir, int repeat) {
}
// namespace paddle
}
// namespace paddle
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
CHECK_EQ
(
argc
,
2
)
<<
"usage: ./cmd <model_dir
>"
;
CHECK_EQ
(
argc
,
3
)
<<
"usage: ./cmd <model_dir> <repeat
>"
;
paddle
::
lite
::
Run
(
argv
[
1
],
1
);
paddle
::
lite
::
Run
(
argv
[
1
],
std
::
stoi
(
argv
[
2
])
);
return
0
;
return
0
;
}
}
...
...
paddle/fluid/lite/core/context.cc
浏览文件 @
f116bb9e
...
@@ -28,6 +28,10 @@
...
@@ -28,6 +28,10 @@
#endif // TARGET_OS_IPHONE
#endif // TARGET_OS_IPHONE
#endif // __APPLE__
#endif // __APPLE__
#ifdef ARM_WITH_OMP
#include <omp.h>
#endif
namespace
paddle
{
namespace
paddle
{
namespace
lite
{
namespace
lite
{
...
@@ -84,7 +88,7 @@ ARMContext& Context<TargetType::kARM>::operator=(const ARMContext& ctx) {
...
@@ -84,7 +88,7 @@ ARMContext& Context<TargetType::kARM>::operator=(const ARMContext& ctx) {
}
}
void
Context
<
TargetType
::
kARM
>::
BindDev
()
{
void
Context
<
TargetType
::
kARM
>::
BindDev
()
{
#ifdef
USE_OPEN
MP
#ifdef
ARM_WITH_O
MP
int
num_threads
=
active_ids_
.
size
();
int
num_threads
=
active_ids_
.
size
();
omp_set_num_threads
(
num_threads
);
omp_set_num_threads
(
num_threads
);
#ifdef LITE_WITH_LINUX
#ifdef LITE_WITH_LINUX
...
@@ -98,12 +102,12 @@ void Context<TargetType::kARM>::BindDev() {
...
@@ -98,12 +102,12 @@ void Context<TargetType::kARM>::BindDev() {
}
}
for
(
int
i
=
0
;
i
<
num_threads
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num_threads
;
i
++
)
{
if
(
ssarets
[
i
]
!=
0
)
{
if
(
ssarets
[
i
]
!=
0
)
{
LOG
E
(
"set cpu affinity failed, cpuID: %d
\n
"
,
active_ids_
[
i
])
;
LOG
(
ERROR
)
<<
"set cpu affinity failed, cpuID: "
<<
active_ids_
[
i
]
;
return
;
return
;
}
}
}
}
#endif // LITE_WITH_LINUX
#endif // LITE_WITH_LINUX
#else //
USE_OPEN
MP
#else //
ARM_WITH_O
MP
#ifdef LITE_WITH_LINUX
#ifdef LITE_WITH_LINUX
std
::
vector
<
int
>
cpuid1
;
std
::
vector
<
int
>
cpuid1
;
cpuid1
.
push_back
(
active_ids_
[
0
]);
cpuid1
.
push_back
(
active_ids_
[
0
]);
...
@@ -113,7 +117,7 @@ void Context<TargetType::kARM>::BindDev() {
...
@@ -113,7 +117,7 @@ void Context<TargetType::kARM>::BindDev() {
return
;
return
;
}
}
#endif // LITE_WITH_LINUX
#endif // LITE_WITH_LINUX
#endif //
USE_OPEN
MP
#endif //
ARM_WITH_O
MP
}
}
void
Context
<
TargetType
::
kARM
>::
SetRunMode
(
PowerMode
mode
,
int
threads
)
{
void
Context
<
TargetType
::
kARM
>::
SetRunMode
(
PowerMode
mode
,
int
threads
)
{
...
@@ -123,7 +127,7 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
...
@@ -123,7 +127,7 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
if
(
threads
>
big_core_size
+
small_core_size
)
{
if
(
threads
>
big_core_size
+
small_core_size
)
{
threads
=
big_core_size
+
small_core_size
;
threads
=
big_core_size
+
small_core_size
;
}
}
#ifdef
USE_OPEN
MP
#ifdef
ARM_WITH_O
MP
count_
++
;
count_
++
;
int
shift_num
=
(
count_
/
10
)
%
big_core_size
;
int
shift_num
=
(
count_
/
10
)
%
big_core_size
;
switch
(
mode
)
{
switch
(
mode
)
{
...
@@ -146,8 +150,8 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
...
@@ -146,8 +150,8 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
if
(
big_core_size
>
0
)
{
if
(
big_core_size
>
0
)
{
mode_
=
LITE_POWER_HIGH
;
mode_
=
LITE_POWER_HIGH
;
if
(
threads
>
big_core_size
)
{
if
(
threads
>
big_core_size
)
{
LOG
E
(
"threads: %d, exceed the big cores size: %d
\n
"
,
threads
,
LOG
(
ERROR
)
<<
"threads: "
<<
threads
big_core_size
)
;
<<
", exceed the big cores size: "
<<
big_core_size
;
active_ids_
=
dev
.
big_core_ids_
;
active_ids_
=
dev
.
big_core_ids_
;
}
else
{
}
else
{
for
(
int
i
=
0
;
i
<
threads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
threads
;
++
i
)
{
...
@@ -156,7 +160,7 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
...
@@ -156,7 +160,7 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
}
}
}
else
{
}
else
{
mode_
=
LITE_POWER_LOW
;
mode_
=
LITE_POWER_LOW
;
LOG
E
(
"HIGH POWER MODE is not support, switch to little cores
\n
"
)
;
LOG
(
ERROR
)
<<
"HIGH POWER MODE is not support, switch to little cores"
;
if
(
threads
>
small_core_size
)
{
if
(
threads
>
small_core_size
)
{
active_ids_
=
dev
.
little_core_ids_
;
active_ids_
=
dev
.
little_core_ids_
;
}
else
{
}
else
{
...
@@ -174,8 +178,8 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
...
@@ -174,8 +178,8 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
if
(
small_core_size
>
0
)
{
if
(
small_core_size
>
0
)
{
mode_
=
LITE_POWER_LOW
;
mode_
=
LITE_POWER_LOW
;
if
(
threads
>
small_core_size
)
{
if
(
threads
>
small_core_size
)
{
LOG
W
(
"threads: %d, exceed the little cores size: %d
\n
"
,
threads
,
LOG
(
WARNING
)
<<
"threads: "
<<
threads
small_core_size
)
;
<<
", exceed the little cores size: "
<<
small_core_size
;
active_ids_
=
dev
.
little_core_ids_
;
active_ids_
=
dev
.
little_core_ids_
;
}
else
{
}
else
{
for
(
int
i
=
0
;
i
<
threads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
threads
;
++
i
)
{
...
@@ -184,7 +188,7 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
...
@@ -184,7 +188,7 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
}
}
}
else
{
}
else
{
mode_
=
LITE_POWER_HIGH
;
mode_
=
LITE_POWER_HIGH
;
LOG
W
(
"LOW POWER MODE is not support, switch to big cores
\n
"
)
;
LOG
(
WARNING
)
<<
"LOW POWER MODE is not support, switch to big cores"
;
if
(
threads
>
big_core_size
)
{
if
(
threads
>
big_core_size
)
{
active_ids_
=
dev
.
big_core_ids_
;
active_ids_
=
dev
.
big_core_ids_
;
}
else
{
}
else
{
...
@@ -211,8 +215,8 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
...
@@ -211,8 +215,8 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
if
(
big_core_size
>
0
)
{
if
(
big_core_size
>
0
)
{
mode_
=
LITE_POWER_RAND_HIGH
;
mode_
=
LITE_POWER_RAND_HIGH
;
if
(
threads
>
big_core_size
)
{
if
(
threads
>
big_core_size
)
{
LOG
W
(
"threads: %d, exceed the big cores size: %d
\n
"
,
threads
,
LOG
(
WARNING
)
<<
"threads: "
<<
threads
big_core_size
)
;
<<
", exceed the big cores size: "
<<
big_core_size
;
active_ids_
=
dev
.
big_core_ids_
;
active_ids_
=
dev
.
big_core_ids_
;
}
else
{
}
else
{
for
(
int
i
=
0
;
i
<
threads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
threads
;
++
i
)
{
...
@@ -222,7 +226,8 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
...
@@ -222,7 +226,8 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
}
}
}
else
{
}
else
{
mode_
=
LITE_POWER_LOW
;
mode_
=
LITE_POWER_LOW
;
LOGW
(
"HIGH POWER MODE is not support, switch to little cores
\n
"
);
LOG
(
WARNING
)
<<
"HIGH POWER MODE is not support, switch to little cores"
;
if
(
threads
>
small_core_size
)
{
if
(
threads
>
small_core_size
)
{
active_ids_
=
dev
.
little_core_ids_
;
active_ids_
=
dev
.
little_core_ids_
;
}
else
{
}
else
{
...
@@ -240,8 +245,8 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
...
@@ -240,8 +245,8 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
if
(
small_core_size
>
0
)
{
if
(
small_core_size
>
0
)
{
mode_
=
LITE_POWER_RAND_LOW
;
mode_
=
LITE_POWER_RAND_LOW
;
if
(
threads
>
small_core_size
)
{
if
(
threads
>
small_core_size
)
{
LOG
W
(
"threads: %d, exceed the little cores size: %d
\n
"
,
threads
,
LOG
(
WARNING
)
<<
"threads: "
<<
threads
small_core_size
)
;
<<
", exceed the little cores size: "
<<
small_core_size
;
active_ids_
=
dev
.
little_core_ids_
;
active_ids_
=
dev
.
little_core_ids_
;
}
else
{
}
else
{
for
(
int
i
=
0
;
i
<
threads
;
++
i
)
{
for
(
int
i
=
0
;
i
<
threads
;
++
i
)
{
...
@@ -251,7 +256,7 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
...
@@ -251,7 +256,7 @@ void Context<TargetType::kARM>::SetRunMode(PowerMode mode, int threads) {
}
}
}
else
{
}
else
{
mode_
=
LITE_POWER_HIGH
;
mode_
=
LITE_POWER_HIGH
;
LOG
W
(
"LOW POWER MODE is not support, switch to big cores
\n
"
)
;
LOG
(
WARNING
)
<<
"LOW POWER MODE is not support, switch to big cores"
;
if
(
threads
>
big_core_size
)
{
if
(
threads
>
big_core_size
)
{
active_ids_
=
dev
.
big_core_ids_
;
active_ids_
=
dev
.
big_core_ids_
;
}
else
{
}
else
{
...
...
paddle/fluid/lite/kernels/arm/conv_compute.cc
浏览文件 @
f116bb9e
...
@@ -28,6 +28,8 @@ void ConvCompute::PrepareForRun() {
...
@@ -28,6 +28,8 @@ void ConvCompute::PrepareForRun() {
auto
o_dims
=
param
.
output
->
dims
();
auto
o_dims
=
param
.
output
->
dims
();
auto
&
ctx
=
this
->
ctx_
->
template
As
<
ARMContext
>();
auto
&
ctx
=
this
->
ctx_
->
template
As
<
ARMContext
>();
// TODO(xxx): make api and expose it
ctx
.
SetRunMode
(
LITE_POWER_HIGH
,
4
);
int
win
=
x_dims
[
3
];
// nchw
int
win
=
x_dims
[
3
];
// nchw
int
hin
=
x_dims
[
2
];
int
hin
=
x_dims
[
2
];
...
...
paddle/fluid/lite/kernels/arm/fc_compute.cc
浏览文件 @
f116bb9e
...
@@ -27,6 +27,9 @@ void FcCompute::PrepareForRun() {
...
@@ -27,6 +27,9 @@ void FcCompute::PrepareForRun() {
auto
x_dims
=
param
.
input
->
dims
();
auto
x_dims
=
param
.
input
->
dims
();
auto
w_dims
=
param
.
w
->
dims
();
auto
w_dims
=
param
.
w
->
dims
();
auto
&
ctx
=
this
->
ctx_
->
template
As
<
ARMContext
>();
ctx
.
SetRunMode
(
LITE_POWER_HIGH
,
4
);
CHECK_GE
(
x_dims
.
size
(),
2UL
);
CHECK_GE
(
x_dims
.
size
(),
2UL
);
CHECK_EQ
(
w_dims
.
size
(),
2UL
);
CHECK_EQ
(
w_dims
.
size
(),
2UL
);
CHECK_EQ
(
param
.
output
->
dims
().
size
(),
2UL
);
CHECK_EQ
(
param
.
output
->
dims
().
size
(),
2UL
);
...
...
paddle/fluid/lite/kernels/arm/mul_compute.cc
浏览文件 @
f116bb9e
...
@@ -23,7 +23,8 @@ namespace kernels {
...
@@ -23,7 +23,8 @@ namespace kernels {
namespace
arm
{
namespace
arm
{
void
MulCompute
::
PrepareForRun
()
{
void
MulCompute
::
PrepareForRun
()
{
// TODO(TJ): transpose x or y if necessary
auto
&
ctx
=
this
->
ctx_
->
template
As
<
ARMContext
>();
ctx
.
SetRunMode
(
LITE_POWER_HIGH
,
4
);
}
}
void
MulCompute
::
Run
()
{
void
MulCompute
::
Run
()
{
...
...
paddle/fluid/lite/kernels/arm/pool_compute.cc
浏览文件 @
f116bb9e
...
@@ -24,6 +24,11 @@ namespace lite {
...
@@ -24,6 +24,11 @@ namespace lite {
namespace
kernels
{
namespace
kernels
{
namespace
arm
{
namespace
arm
{
void
PoolCompute
::
PrepareForRun
()
{
auto
&
ctx
=
this
->
ctx_
->
template
As
<
ARMContext
>();
ctx
.
SetRunMode
(
LITE_POWER_HIGH
,
4
);
}
void
PoolCompute
::
Run
()
{
void
PoolCompute
::
Run
()
{
auto
&
param
=
Param
<
operators
::
PoolParam
>
();
auto
&
param
=
Param
<
operators
::
PoolParam
>
();
auto
&
in_dims
=
param
.
x
->
dims
();
auto
&
in_dims
=
param
.
x
->
dims
();
...
...
paddle/fluid/lite/kernels/arm/pool_compute.h
浏览文件 @
f116bb9e
...
@@ -26,6 +26,7 @@ class PoolCompute : public KernelLite<TARGET(kARM), PRECISION(kFloat)> {
...
@@ -26,6 +26,7 @@ class PoolCompute : public KernelLite<TARGET(kARM), PRECISION(kFloat)> {
public:
public:
using
param_t
=
operators
::
PoolParam
;
using
param_t
=
operators
::
PoolParam
;
void
PrepareForRun
()
override
;
void
Run
()
override
;
void
Run
()
override
;
TargetType
target
()
const
override
;
TargetType
target
()
const
override
;
...
...
paddle/fluid/lite/tools/build.sh
浏览文件 @
f116bb9e
...
@@ -56,7 +56,7 @@ function check_style {
...
@@ -56,7 +56,7 @@ function check_style {
function
cmake_arm
{
function
cmake_arm
{
# $1: ARM_TARGET_OS in "android" , "armlinux"
# $1: ARM_TARGET_OS in "android" , "armlinux"
# $2: ARM_TARGET_ARCH_ABI in "arm
64-v8a", "armeabi-v7a" ,"armeabi-v7a-
hf"
# $2: ARM_TARGET_ARCH_ABI in "arm
v8", "armv7" ,"armv7
hf"
cmake ..
\
cmake ..
\
-DWITH_GPU
=
OFF
\
-DWITH_GPU
=
OFF
\
-DWITH_MKL
=
OFF
\
-DWITH_MKL
=
OFF
\
...
@@ -123,31 +123,24 @@ function test_arm_android {
...
@@ -123,31 +123,24 @@ function test_arm_android {
# Build the code and run lite arm tests. This is executed in the CI system.
# Build the code and run lite arm tests. This is executed in the CI system.
function
build_test_arm
{
function
build_test_arm
{
port_armv8
=
5554
# 1. Build goes first
port_armv7
=
5556
adb kill-server
adb devices |
grep
emulator |
cut
-f1
|
while
read
line
;
do
adb
-s
$line
emu
kill
;
done
# start android arm64-v8a armeabi-v7a emulators first
echo
n | avdmanager create avd
-f
-n
paddle-armv8
-k
"system-images;android-24;google_apis;arm64-v8a"
echo
-ne
'\n'
|
${
ANDROID_HOME
}
/emulator/emulator
-avd
paddle-armv8
-noaudio
-no-window
-gpu
off
-verbose
-port
${
port_armv8
}
&
sleep
1m
echo
n | avdmanager create avd
-f
-n
paddle-armv7
-k
"system-images;android-24;google_apis;armeabi-v7a"
echo
-ne
'\n'
|
${
ANDROID_HOME
}
/emulator/emulator
-avd
paddle-armv7
-noaudio
-no-window
-gpu
off
-verbose
-port
${
port_armv7
}
&
sleep
1m
cur_dir
=
$(
pwd
)
cur_dir
=
$(
pwd
)
for
os
in
"android"
"armlinux"
;
do
for
os
in
"android"
"armlinux"
;
do
for
abi
in
"arm64-v8a"
"armeabi-v7a"
"armeabi-v7a-hf"
;
do
for
abi
in
"armv8"
"armv7"
"armv7hf"
;
do
# TODO(TJ): enable compile on v7-hf on andorid and all v7 on armlinux
# TODO(hongming): enable compile armv7 and armv7hf on armlinux
if
[[
${
abi
}
==
"armeabi-v7a-hf"
]]
;
then
if
[[
${
abi
}
==
"armv7hf"
]]
;
then
echo
"armeabi-v7a-hf is not supported on both android and armlinux"
echo
"armv7hf is not supported on both android and armlinux yet"
continue
fi
# TODO(hongming): enable armv7 on armlinux
if
[[
${
os
}
==
"armlinux"
&&
${
abi
}
==
"armv7"
]]
;
then
echo
"armv7 is not supported on armlinux yet"
continue
continue
fi
fi
if
[[
${
os
}
==
"a
rmlinux"
&&
${
abi
}
==
"armeabi-v7a
"
]]
;
then
if
[[
${
os
}
==
"a
ndroid"
&&
${
abi
}
==
"armv7hf
"
]]
;
then
echo
"a
rmeabi-v7a is not supported on armlinux yet
"
echo
"a
ndroid do not need armv7hf
"
continue
continue
fi
fi
...
@@ -157,34 +150,50 @@ function build_test_arm {
...
@@ -157,34 +150,50 @@ function build_test_arm {
cmake_arm
${
os
}
${
abi
}
cmake_arm
${
os
}
${
abi
}
build
$TESTS_FILE
build
$TESTS_FILE
done
done
# armlinux need in another docker
# 2. Then test
# TODO(TJ): enable test with armlinux
port_armv8
=
5554
if
[[
${
os
}
==
"android"
]]
;
then
port_armv7
=
5556
adb_abi
=
${
abi
}
if
[[
${
adb_abi
}
==
"armeabi-v7a-hf"
]]
;
then
adb kill-server
adb_abi
=
"armeabi-v7a"
adb devices |
grep
emulator |
cut
-f1
|
while
read
line
;
do
adb
-s
$line
emu
kill
;
done
fi
# start android armv8 and armv7 emulators first
if
[[
${
adb_abi
}
==
"armeabi-v7a"
]]
;
then
echo
n | avdmanager create avd
-f
-n
paddle-armv8
-k
"system-images;android-24;google_apis;arm64-v8a"
# skip all armv7 tests
echo
-ne
'\n'
|
${
ANDROID_HOME
}
/emulator/emulator
-avd
paddle-armv8
-noaudio
-no-window
-gpu
off
-verbose
-port
${
port_armv8
}
&
# TODO(TJ): enable test with armv7
sleep
1m
continue
echo
n | avdmanager create avd
-f
-n
paddle-armv7
-k
"system-images;android-24;google_apis;armeabi-v7a"
fi
echo
-ne
'\n'
|
${
ANDROID_HOME
}
/emulator/emulator
-avd
paddle-armv7
-noaudio
-no-window
-gpu
off
-verbose
-port
${
port_armv7
}
&
local
port
=
sleep
1m
if
[[
${
adb_abi
}
==
"armeabi-v7a"
]]
;
then
port
=
${
port_armv7
}
# now can only test android.
fi
for
abi
in
"armv8"
"armv7"
;
do
# TODO(yuanshuai): enable armv7 on android
if
[[
${
adb_abi
}
==
"arm64-v8a"
]]
;
then
if
[[
${
abi
}
==
"armv7"
]]
;
then
port
=
${
port_armv8
}
continue
fi
fi
echo
"test file:
${
TESTS_FILE
}
"
for
_test
in
$(
cat
$TESTS_FILE
)
;
do
build_dir
=
$cur_dir
/build.lite.android.
${
abi
}
test_arm_android
$_test
$port
cd
$build_dir
done
fi
local
port
=
if
[[
${
abi
}
==
"armv7"
]]
;
then
port
=
${
port_armv7
}
fi
if
[[
${
abi
}
==
"armv8"
]]
;
then
port
=
${
port_armv8
}
fi
echo
"test file:
${
TESTS_FILE
}
"
for
_test
in
$(
cat
$TESTS_FILE
)
;
do
test_arm_android
$_test
$port
done
done
done
done
# armlinux need in another docker
# TODO(hongming): enable test armlinux on armv8, armv7 and armv7hf
adb devices |
grep
emulator |
cut
-f1
|
while
read
line
;
do
adb
-s
$line
emu
kill
;
done
adb devices |
grep
emulator |
cut
-f1
|
while
read
line
;
do
adb
-s
$line
emu
kill
;
done
echo
"Done"
echo
"Done"
}
}
...
...
paddle/fluid/lite/tools/mobile_readme.md
浏览文件 @
f116bb9e
...
@@ -17,8 +17,15 @@ $ git checkout incubate/lite
...
@@ -17,8 +17,15 @@ $ git checkout incubate/lite
### 主要cmake选项
### 主要cmake选项
-
`ARM_TARGET_OS`
代表目标操作系统, 目前支持 "android" "armlinux", 模型是Android
-
`ARM_TARGET_OS`
代表目标操作系统, 目前支持 "android" "armlinux", 默认是Android
-
`ARM_TARGET_ARCH_ABI`
代表ARCH, 目前支持 "arm64-v8a" "armeabi-v7a"。 模型是arm64-v8a
-
`ARM_TARGET_ARCH_ABI`
代表ARCH,支持输入"armv8"和"armv7",针对OS不一样选择不一样。
-
`-DARM_TARGET_OS="android"`
时
-
"armv8", 等效于 "arm64-v8a"。 default值为这个。
-
"armv7", 等效于 "armeabi-v7a"。
-
`-DARM_TARGET_OS="armlinux"`
时
-
"armv8", 等效于 "arm64"。 default值为这个。
-
"armv7hf", 等效于使用
`eabihf`
且
`-march=armv7-a -mfloat-abi=hard -mfpu=neon-vfpv4 `
。
-
"armv7", 等效于使用
`eabi`
且
`-march=armv7-a -mfloat-abi=softfp -mfpu=neon-vfpv4`
。
### 编译
### 编译
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录