Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle-Lite
提交
54aac038
P
Paddle-Lite
项目概览
PaddlePaddle
/
Paddle-Lite
通知
331
Star
4
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
271
列表
看板
标记
里程碑
合并请求
78
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle-Lite
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
271
Issue
271
列表
看板
标记
里程碑
合并请求
78
合并请求
78
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
54aac038
编写于
7月 24, 2018
作者:
H
hanbuhe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add support for multiple nets
上级
c0019508
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
91 addition
and
45 deletion
+91
-45
CMakeLists.txt
CMakeLists.txt
+2
-2
tools/build.sh
tools/build.sh
+39
-30
tools/op.cmake
tools/op.cmake
+50
-13
未找到文件。
CMakeLists.txt
浏览文件 @
54aac038
...
@@ -140,8 +140,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build)
...
@@ -140,8 +140,8 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build)
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY build
)
set
(
CMAKE_RUNTIME_OUTPUT_DIRECTORY build
)
# NET default
# NET default
set
(
NET
"defult"
CACHE STRING
"select net type"
)
set
(
NET
"def
a
ult"
CACHE STRING
"select net type"
)
set_property
(
CACHE NET PROPERTY STRINGS
"defult"
"googlenet"
"mobilenet"
"yolo"
"squeezenet"
"FPGAnets"
)
set_property
(
CACHE NET PROPERTY STRINGS
"def
a
ult"
"googlenet"
"mobilenet"
"yolo"
"squeezenet"
"FPGAnets"
)
include
(
"
${
CMAKE_CURRENT_LIST_DIR
}
/tools/op.cmake"
)
include
(
"
${
CMAKE_CURRENT_LIST_DIR
}
/tools/op.cmake"
)
...
...
tools/build.sh
浏览文件 @
54aac038
#!/usr/bin/env bash
#!/usr/bin/env bash
NETS
=
""
declare
-a
supportedNets
=(
"googlenet"
"mobilenet"
"yolo"
"squeezenet"
"resnet"
)
build_for_mac
()
{
build_for_mac
()
{
if
[
!
`
which brew
`
]
;
then
if
[
!
`
which brew
`
]
;
then
...
@@ -60,7 +62,8 @@ build_for_android() {
...
@@ -60,7 +62,8 @@ build_for_android() {
ANDROID_PLATFORM_VERSION
=
"android-22"
ANDROID_PLATFORM_VERSION
=
"android-22"
TOOLCHAIN_FILE
=
"./tools/android-cmake/android.toolchain.cmake"
TOOLCHAIN_FILE
=
"./tools/android-cmake/android.toolchain.cmake"
ANDROID_ARM_MODE
=
"arm"
ANDROID_ARM_MODE
=
"arm"
if
[
$#
-eq
1
]
;
then
if
[
"
${#
NETS
}
"
>
1
]
;
then
cmake ..
\
cmake ..
\
-B
"../build/release/
${
PLATFORM
}
"
\
-B
"../build/release/
${
PLATFORM
}
"
\
-DANDROID_ABI
=
"
${
ABI
}
"
\
-DANDROID_ABI
=
"
${
ABI
}
"
\
...
@@ -70,7 +73,7 @@ build_for_android() {
...
@@ -70,7 +73,7 @@ build_for_android() {
-DCMAKE_CXX_FLAGS
=
"
${
CXX_FLAGS
}
"
\
-DCMAKE_CXX_FLAGS
=
"
${
CXX_FLAGS
}
"
\
-DANDROID_STL
=
c++_static
\
-DANDROID_STL
=
c++_static
\
-DANDROID
=
true
\
-DANDROID
=
true
\
-DNET
=
$1
\
-DNET
=
"
${
NETS
}
"
\
-D
"
${
ARM_PLATFORM
}
"
=
true
-D
"
${
ARM_PLATFORM
}
"
=
true
else
else
...
@@ -96,14 +99,14 @@ build_for_ios() {
...
@@ -96,14 +99,14 @@ build_for_ios() {
BUILD_DIR
=
../build/release/
"
${
PLATFORM
}
"
/
BUILD_DIR
=
../build/release/
"
${
PLATFORM
}
"
/
TOOLCHAIN_FILE
=
"./tools/ios-cmake/ios.toolchain.cmake"
TOOLCHAIN_FILE
=
"./tools/ios-cmake/ios.toolchain.cmake"
mkdir
-p
"
${
BUILD_DIR
}
"
mkdir
-p
"
${
BUILD_DIR
}
"
if
[
$#
-eq
1
]
;
then
if
[
"
${#
NETS
}
"
>
1
]
;
then
cmake ..
\
cmake ..
\
-B
"
${
BUILD_DIR
}
"
\
-B
"
${
BUILD_DIR
}
"
\
-DCMAKE_BUILD_TYPE
=
"
${
MODE
}
"
\
-DCMAKE_BUILD_TYPE
=
"
${
MODE
}
"
\
-DIOS_PLATFORM
=
OS
\
-DIOS_PLATFORM
=
OS
\
-DIOS_ARCH
=
"
${
IOS_ARCH
}
"
\
-DIOS_ARCH
=
"
${
IOS_ARCH
}
"
\
-DCMAKE_TOOLCHAIN_FILE
=
"
${
TOOLCHAIN_FILE
}
"
\
-DCMAKE_TOOLCHAIN_FILE
=
"
${
TOOLCHAIN_FILE
}
"
\
-DNET
=
$1
\
-DNET
=
"
${
NETS
}
"
\
-DIS_IOS
=
"true"
-DIS_IOS
=
"true"
else
else
cmake ..
\
cmake ..
\
...
@@ -123,7 +126,7 @@ build_for_ios() {
...
@@ -123,7 +126,7 @@ build_for_ios() {
}
}
build_error
()
{
build_error
()
{
echo
"unknown
argument
"
echo
"unknown
target :
$1
"
}
}
if
[
$#
-lt
1
]
;
then
if
[
$#
-lt
1
]
;
then
...
@@ -131,31 +134,37 @@ if [ $# -lt 1 ]; then
...
@@ -131,31 +134,37 @@ if [ $# -lt 1 ]; then
echo
"available targets: ios|android"
echo
"available targets: ios|android"
echo
"sample usage: ./build.sh android"
echo
"sample usage: ./build.sh android"
else
else
if
[
$#
-eq
2
]
;
then
params
=(
$@
)
if
[
$2
!=
"googlenet"
-a
$2
!=
"mobilenet"
-a
$2
!=
"yolo"
-a
$2
!=
"squeezenet"
-a
$2
!=
"resnet"
]
;
then
for
((
i
=
1
;
i<
$#;
i++
))
;
do
if
[
$1
=
"android"
]
;
then
if
[
${
i
}
!=
1
]
;
then
build_for_android
NETS
=
$NETS
$";"
elif
[
$1
=
"ios"
]
;
then
fi
build_for_ios
NETS
=
$NETS
$"
${
params
[i]
}
"
else
done
build_error
params
=
${
@
:2
}
fi
else
supported
=
false
if
[
$1
=
"android"
]
;
then
for
name
in
${
params
[@]
}
;
do
build_for_android
$2
for
net
in
${
supportedNets
[@]
}
;
do
elif
[
$1
=
"ios"
]
;
then
match
=
false
build_for_ios
$2
if
[
"
$name
"
x
=
"
$net
"
x
]
;
then
else
supported
=
true
build_error
match
=
true
fi
break
1
fi
done
if
[
"
$match
"
=
false
]
;
then
echo
"
${
name
}
not supported!"
echo
"supported nets are:
${
supportedNets
[@]
}
"
exit
-1
fi
fi
done
if
[
$1
=
"android"
]
;
then
build_for_android
elif
[
$1
=
"ios"
]
;
then
build_for_ios
else
else
if
[
$1
=
"android"
]
;
then
build_error
"
$1
"
build_for_android
fi
elif
[
$1
=
"ios"
]
;
then
build_for_ios
else
build_error
fi
fi
fi
fi
\ No newline at end of file
tools/op.cmake
浏览文件 @
54aac038
if
(
NET STREQUAL
"googlenet"
)
set
(
FOUND_MATCH OFF
)
if
(
"googlenet"
IN_LIST NET
)
message
(
"googlenet enabled"
)
set
(
CONCAT_OP ON
)
set
(
CONCAT_OP ON
)
set
(
CONV_OP ON
)
set
(
CONV_OP ON
)
set
(
LRN_OP ON
)
set
(
LRN_OP ON
)
...
@@ -9,7 +11,12 @@ if (NET STREQUAL "googlenet")
...
@@ -9,7 +11,12 @@ if (NET STREQUAL "googlenet")
set
(
RELU_OP ON
)
set
(
RELU_OP ON
)
set
(
FUSION_CONVADD_OP ON
)
set
(
FUSION_CONVADD_OP ON
)
set
(
FUSION_CONVADD_RELU_OP ON
)
set
(
FUSION_CONVADD_RELU_OP ON
)
elseif
(
NET STREQUAL
"mobilenet"
)
set
(
FOUND_MATCH ON
)
endif
()
if
(
"mobilenet"
IN_LIST NET
)
message
(
"mobilenet enabled"
)
set
(
CONV_OP ON
)
set
(
CONV_OP ON
)
set
(
ELEMENTWISEADD_OP ON
)
set
(
ELEMENTWISEADD_OP ON
)
set
(
RELU_OP ON
)
set
(
RELU_OP ON
)
...
@@ -21,12 +28,23 @@ elseif (NET STREQUAL "mobilenet")
...
@@ -21,12 +28,23 @@ elseif (NET STREQUAL "mobilenet")
set
(
RESHAPE_OP ON
)
set
(
RESHAPE_OP ON
)
set
(
FUSION_CONVADDBNRELU_OP ON
)
set
(
FUSION_CONVADDBNRELU_OP ON
)
set
(
FUSION_CONVADD_OP ON
)
set
(
FUSION_CONVADD_OP ON
)
elseif
(
NET STREQUAL
"yolo"
)
set
(
FOUND_MATCH ON
)
endif
()
if
(
"yolo"
IN_LIST NET
)
message
(
"yolo enabled"
)
set
(
BATCHNORM_OP ON
)
set
(
BATCHNORM_OP ON
)
set
(
CONV_OP ON
)
set
(
CONV_OP ON
)
set
(
RELU_OP ON
)
set
(
RELU_OP ON
)
set
(
ELEMENTWISEADD_OP ON
)
set
(
ELEMENTWISEADD_OP ON
)
elseif
(
NET STREQUAL
"squeezenet"
)
set
(
FOUND_MATCH ON
)
endif
()
if
(
"squeezenet"
IN_LIST NET
)
message
(
"squeezenet enabled"
)
set
(
CONCAT_OP ON
)
set
(
CONCAT_OP ON
)
set
(
CONV_OP ON
)
set
(
CONV_OP ON
)
set
(
RELU_OP ON
)
set
(
RELU_OP ON
)
...
@@ -34,15 +52,26 @@ elseif (NET STREQUAL "squeezenet")
...
@@ -34,15 +52,26 @@ elseif (NET STREQUAL "squeezenet")
set
(
POOL_OP ON
)
set
(
POOL_OP ON
)
set
(
RESHAPE_OP ON
)
set
(
RESHAPE_OP ON
)
set
(
SOFTMAX_OP ON
)
set
(
SOFTMAX_OP ON
)
elseif
(
NET STREQUAL
"resnet"
)
set
(
FOUND_MATCH ON
)
endif
()
if
(
"resnet"
IN_LIST NET
)
message
(
"resnet enabled"
)
set
(
CONCAT_OP ON
)
set
(
CONV_OP ON
)
set
(
CONV_OP ON
)
set
(
BATCHNORM
_OP ON
)
set
(
RELU
_OP ON
)
set
(
ELEMENTWISEADD_OP ON
)
set
(
ELEMENTWISEADD_OP ON
)
set
(
SOFTMAX_OP ON
)
set
(
MUL_OP ON
)
set
(
POOL_OP ON
)
set
(
POOL_OP ON
)
set
(
RELU_OP ON
)
set
(
RESHAPE_OP ON
)
elseif
(
NET STREQUAL
"FPGAnets"
)
set
(
SOFTMAX_OP ON
)
set
(
FOUND_MATCH ON
)
endif
()
if
(
"FPGAnets"
IN_LIST NET
)
message
(
"FPGAnets enabled"
)
set
(
FUSION_CONVRELU_OP ON
)
set
(
FUSION_CONVRELU_OP ON
)
set
(
FUSION_CONVBNSCALE_OP ON
)
set
(
FUSION_CONVBNSCALE_OP ON
)
set
(
FUSION_CONVBNSCALERELU_OP ON
)
set
(
FUSION_CONVBNSCALERELU_OP ON
)
...
@@ -51,8 +80,14 @@ elseif (NET STREQUAL "FPGAnets")
...
@@ -51,8 +80,14 @@ elseif (NET STREQUAL "FPGAnets")
set
(
REGION_OP ON
)
set
(
REGION_OP ON
)
set
(
POOL_OP ON
)
set
(
POOL_OP ON
)
set
(
CONCAT_OP ON
)
set
(
CONCAT_OP ON
)
set
(
SOFTMAX_OP ON
)
set
(
SOFTMAX_OP ON
)
else
()
set
(
FOUND_MATCH ON
)
endif
()
if
(
NOT FOUND_MATCH
)
message
(
"--default--"
)
set
(
BATCHNORM_OP ON
)
set
(
BATCHNORM_OP ON
)
set
(
BOXCODER_OP ON
)
set
(
BOXCODER_OP ON
)
set
(
CONCAT_OP ON
)
set
(
CONCAT_OP ON
)
...
@@ -82,6 +117,8 @@ else ()
...
@@ -82,6 +117,8 @@ else ()
set
(
SLICE_OP ON
)
set
(
SLICE_OP ON
)
set
(
DROPOUT_OP ON
)
set
(
DROPOUT_OP ON
)
set
(
IM2SEQUENCE_OP ON
)
set
(
IM2SEQUENCE_OP ON
)
endif
()
# option(BATCHNORM_OP "" ON)
# option(BATCHNORM_OP "" ON)
# option(BOXCODER_OP "" ON)
# option(BOXCODER_OP "" ON)
# option(CONCAT_OP "" ON)
# option(CONCAT_OP "" ON)
...
@@ -102,7 +139,7 @@ else ()
...
@@ -102,7 +139,7 @@ else ()
# option(SOFTMAX_OP "" ON)
# option(SOFTMAX_OP "" ON)
# option(TRANSPOSE_OP "" ON)
# option(TRANSPOSE_OP "" ON)
# option(FUSION_CONVADD_RELU_OP "" ON)
# option(FUSION_CONVADD_RELU_OP "" ON)
endif
()
#
endif ()
if
(
BATCHNORM_OP
)
if
(
BATCHNORM_OP
)
add_definitions
(
-DBATCHNORM_OP
)
add_definitions
(
-DBATCHNORM_OP
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录