diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f037c79962058dfc39b4cc598c0ee9106a10f88..6feabdbe4374c9200c4282f620fadc27f3128bc9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,12 +6,12 @@ option(USE_OPENMP "openmp support" OFF) option(USE_EXCEPTION "use std exception" ON) option(LOG_PROFILE "log profile" ON) # select the platform to build -option(CPU "cpu" OFF) +option(CPU "armv7 with neon" ON) option(MALI_GPU "mali gpu" ON) option(FPGA "fpga" OFF) - +set(DEBUGING ON) if (CPU) - add_definitions(-DPADDLE_MOBILE_CPU) + add_definitions(-DPADDLE_MOBILE_CPU) endif() if (MALI_GPU) @@ -30,29 +30,26 @@ if (MALI_GPU) endif() if(FPGA) - add_definitions(-DPADDLE_MOBILE_FPGA) + add_definitions(-DPADDLE_MOBILE_FPGA) endif() + set(CMAKE_CXX_FLAGS "-std=c++14 -O3 -s ${CMAKE_CXX_FLAGS}") -if (DEBUGING) - set(CMAKE_BUILD_TYPE Debug) - set(CMAKE_CXX_FLAGS_DEBUG "-O3 -DNDEBUG") -else() - set(CMAKE_BUILD_TYPE Release) - set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG") -endif () -if(DEBUGING) - message(STATUS "debuging") - add_definitions(-DPADDLE_MOBILE_DEBUG) - if(ANDROID) +if (DEBUGING) + message(STATUS "debug") + set(CMAKE_BUILD_TYPE Debug) + set(CMAKE_CXX_FLAGS_DEBUG "-g -DNDEBUG") + add_definitions(-DPADDLE_MOBILE_DEBUG) + if (ANDROID_NDK_TOOLCHAIN_INCLUDED) + add_definitions(-DARMV7) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -llog") - endif() - -else() - message(STATUS "releasing") - add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden) -endif() + endif () +else () + set(CMAKE_BUILD_TYPE Release) + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") + add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden) +endif () if (USE_EXCEPTION) message(STATUS "use exception") @@ -66,110 +63,37 @@ if (LOG_PROFILE) add_definitions(-DPADDLE_MOBILE_PROFILE) endif() -if(IS_MAC) - add_definitions(-DX86) -elseif(IS_IOS) - add_definitions(-DIOS) -elseif(V7) - add_definitions(-DARMV7) -elseif(V8) - add_definitions(-DARMV8) -else () - add_definitions(-DX86) +if(USE_OPENMP) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") + add_definitions(-DPADDLE_MOBILE_USE_OPENMP) endif() -set(CMAKE_VERBOSE_MAKEFILE ON) -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY build) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build) file(GLOB_RECURSE PADDLE_MOBILE_CC src/*.cc src/*.cpp src/*.c) file(GLOB_RECURSE PADDLE_MOBILE_H src/*.h) -if (NOT ANDROID) -list(REMOVE_ITEM PADDLE_MOBILE_CC ${CMAKE_CURRENT_SOURCE_DIR}/src/jni/*.cpp) -list(REMOVE_ITEM PADDLE_MOBILE_CC ${CMAKE_CURRENT_SOURCE_DIR}/src/jni/*.h) -list(REMOVE_ITEM PADDLE_MOBILE_CC ${CMAKE_CURRENT_SOURCE_DIR}/src/operators/math/math_func_neon.h) +if (NOT ANDROID_NDK_TOOLCHAIN_INCLUDED) + list(REMOVE_ITEM PADDLE_MOBILE_CC ${CMAKE_CURRENT_SOURCE_DIR}/src/jni/*.cpp) + list(REMOVE_ITEM PADDLE_MOBILE_CC ${CMAKE_CURRENT_SOURCE_DIR}/src/jni/*.h) + list(REMOVE_ITEM PADDLE_MOBILE_CC ${CMAKE_CURRENT_SOURCE_DIR}/src/operators/math/math_func_neon.h) endif () include_directories(src/) -if(USE_OPENMP) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp") - add_definitions(-DPADDLE_MOBILE_USE_OPENMP) -endif() +set(CMAKE_VERBOSE_MAKEFILE ON) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY build) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY build) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY build) -if (googlenet) - add_definitions(-DCONCAT_OP) - add_definitions(-DCONV_OP) - add_definitions(-DLRN_OP) - add_definitions(-DMUL_OP) - add_definitions(-DELEMENTWISEADD_OP) - add_definitions(-DFUSION_FC_OP) - add_definitions(-DPOOL_OP) - add_definitions(-DRELU_OP) - add_definitions(-DFUSION_CONVADD_OP) - add_definitions(-DFUSION_CONVADD_RELU_OP) -elseif (mobilenet) - add_definitions(-DCONV_OP) - add_definitions(-DELEMENTWISEADD_OP) - add_definitions(-DRELU_OP) - add_definitions(-DSOFTMAX_OP) - add_definitions(-DSOFTMAX_OP) - add_definitions(-DDEPTHWISECONV_OP) - add_definitions(-DBATCHNORM_OP) - add_definitions(-DPOOL_OP) - add_definitions(-DRESHAPE_OP) -elseif (yolo) - add_definitions(-DBATCHNORM_OP) - add_definitions(-DCONV_OP) - add_definitions(-DRELU_OP) - add_definitions(-DELEMENTWISEADD_OP) -elseif (squeezenet) - add_definitions(-DCONCAT_OP) - add_definitions(-DCONV_OP) - add_definitions(-DRELU_OP) - add_definitions(-DELEMENTWISEADD_OP) - add_definitions(-DPOOL_OP) - add_definitions(-DRESHAPE_OP) - add_definitions(-DSOFTMAX_OP) -elseif(resnet) - add_definitions(-DCONV_OP) - add_definitions(-DBATCHNORM_OP) - add_definitions(-DELEMENTWISEADD_OP) - add_definitions(-DSOFTMAX_OP) - add_definitions(-DMUL_OP) - add_definitions(-DPOOL_OP) - add_definitions(-DRELU_OP) -else () - add_definitions(-DBATCHNORM_OP) - add_definitions(-DBOXCODER_OP) - add_definitions(-DCONCAT_OP) - add_definitions(-DCONV_OP) - add_definitions(-DDEPTHWISECONV_OP) - add_definitions(-DELEMENTWISEADD_OP) - add_definitions(-DFUSION_CONVADD_OP) - add_definitions(-DCONVADDRELU_OP) - add_definitions(-DFUSION_FC_OP) - add_definitions(-DLRN_OP) - add_definitions(-DMUL_OP) - add_definitions(-DMULTICLASSNMS_OP) - add_definitions(-DPOOL_OP) - add_definitions(-DPRIORBOX_OP) - add_definitions(-DRELU_OP) - add_definitions(-DRESHAPE_OP) - add_definitions(-DSIGMOID_OP) - add_definitions(-DSOFTMAX_OP) - add_definitions(-DTRANSPOSE_OP) - add_definitions(-DFUSION_CONVADD_RELU_OP) -endif() +include("${CMAKE_CURRENT_LIST_DIR}/tools/op.cmake") -if (IS_IOS) - add_library(paddle-mobile STATIC ${PADDLE_MOBILE_CC} ${PADDLE_MOBILE_H}) -elseif(ANDROID) +# if (IS_IOS) +# add_library(paddle-mobile STATIC ${PADDLE_MOBILE_CC} ${PADDLE_MOBILE_H}) +if (ANDROID_NDK_TOOLCHAIN_INCLUDED) + list(REMOVE_DUPLICATES CMAKE_CXX_FLAGS) add_library(paddle-mobile SHARED ${PADDLE_MOBILE_CC} ${PADDLE_MOBILE_H}) -else() +else () add_library(paddle-mobile SHARED ${PADDLE_MOBILE_CC} ${PADDLE_MOBILE_H}) endif () diff --git a/Dockerfile b/Dockerfile index 0a249af932f82e9f8d29dcaf739d8ea663965626..82a08b3a2764841b13a1380647efadb3399fc3ec 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,33 @@ -FROM ubuntu:18.04 +FROM ubuntu:16.04 RUN echo '\ -deb bionic main restricted universe multiverse\n\ -deb bionic-updates main restricted universe multiverse\n\ -deb bionic-backports main restricted universe multiverse\n\ -deb bionic-security main restricted universe multiverse\n'\ +deb main restricted universe multiverse\n\ +deb -updates main restricted universe multiverse\n\ +deb -backports main restricted universe multiverse\n\ +deb -security main restricted universe multiverse\n'\ > /etc/apt/sources.list RUN sed -ie 's||http://mirrors.tuna.tsinghua.edu.cn/ubuntu/|' /etc/apt/sources.list +RUN sed -ie 's||xenial|' /etc/apt/sources.list RUN apt-get update && apt-get upgrade -y RUN apt-get install -y --no-install-recommends \ curl \ unzip \ git \ + make \ cmake \ + cmake-curses-gui \ python \ python-pip \ python-setuptools \ clang-format-5.0 \ - graphviz + graphviz \ + g++-arm-linux-gnueabi \ + gcc-arm-linux-gnueabi RUN apt-get autoremove -y && apt-get clean -RUN pip install wheel pre-commit -RUN pre-commit autoupdate +RUN pip install --upgrade pip +RUN pip install wheel && pip install pre-commit RUN ln -s clang-format-5.0 /usr/bin/clang-format -RUN cd /tmp && curl -O http://mirrors.neusoft.edu.cn/android/repository/android-ndk-r17b-linux-x86_64.zip -RUN cd /opt && unzip /tmp/android-ndk-r17b-linux-x86_64.zip \ No newline at end of file +# RUN cd /tmp && curl -O http://mirrors.neusoft.edu.cn/android/repository/android-ndk-r17b-linux-x86_64.zip +# RUN cd /opt && unzip /tmp/android-ndk-r17b-linux-x86_64.zip +# ENV NDK_ROOT /opt/android-ndk-r17b diff --git a/doc/build.md b/doc/build.md new file mode 100644 index 0000000000000000000000000000000000000000..6a8521b593ccdeab464687e7eae79192d131d51b --- /dev/null +++ b/doc/build.md @@ -0,0 +1,59 @@ +# 环境搭建 +## 使用 docker +### 1. 安装 docker +安装 docker 的方式,参考官方文档 [https://docs.docker.com/install/](https://docs.docker.com/install/) +### 2. 使用 docker 搭建构建环境 +首先进入 paddle-mobile 的目录下,执行 `docker build` +以 Linux/Mac 为例 (windows 建议在 'Docker Quickstart Terminal' 中执行) +``` +$ docker build -t paddle-mobile:dev - < Dockerfile +``` +使用 `docker images` 可以看到我们新建的 image +``` +$ docker images +REPOSITORY TAG IMAGE ID CREATED SIZE +paddle-mobile dev 33b146787711 45 hours ago 372MB +``` +### 3. 使用 docker 构建 +进入 paddle-mobile 目录,执行 docker run +``` +$ docker run -it --mount type=bind,source=$PWD,target=/paddle-mobile paddle-mobile:dev +root@5affd29d4fc5:/ # cd /paddle-mobile +# 生成构建 android 产出的 Makefile +root@5affd29d4fc5:/ # rm CMakeCache.txt +root@5affd29d4fc5:/ # cmake -DCMAKE_TOOLCHAIN_FILE=tools/toolchains/arm-android-neon.cmake +# 生成构建 linux 产出的 Makefile +root@5affd29d4fc5:/ # rm CMakeCache.txt +root@5affd29d4fc5:/ # cmake -DCMAKE_TOOLCHAIN_FILE=tools/toolchains/arm-linux-gnueabi.cmake +``` +### 4. 设置编译选项 +可以通过 ccmake 设置编译选项 +``` +root@5affd29d4fc5:/ # ccmake . + Page 1 of 1 + CMAKE_ASM_FLAGS + CMAKE_ASM_FLAGS_DEBUG + CMAKE_ASM_FLAGS_RELEASE + CMAKE_BUILD_TYPE + CMAKE_INSTALL_PREFIX /usr/local + CMAKE_TOOLCHAIN_FILE /paddle-mobile/tools/toolchains/arm-android-neon.cmake + CPU ON + DEBUGING ON + FPGA OFF + LOG_PROFILE ON + MALI_GPU OFF + NET googlenet + USE_EXCEPTION ON + USE_OPENMP OFF +``` +修改选项后,按 `c`, `g` 更新 Makefile +### 5. 构建 +使用 make 命令进行构建 +``` +root@5affd29d4fc5:/ # make +``` +### 6. 查看构建产出 +构架产出可以在 host 机器上查看,在 paddle-mobile 的目录下,build 以及 test/build 下,可以使用 adb 指令或者 scp 传输到 device 上执行 + +## 不使用 docker +不使用 docker 的方法,可以直接用 cmake 生成 makefile 后构建。使用 ndk 构建 android 应用需要正确设置 NDK_ROOT。构建 linux 应用需要安装 arm-linux-gnueabi-gcc 或者类似的交叉编译工具,可能需要设置 CC,CXX 环境变量,或者在 tools/toolchains/ 中修改 arm-linux-gnueabi.cmake,或者增加自己需要的 toolchain file。 \ No newline at end of file diff --git a/src/common/depCore.h b/src/common/dep_core.h similarity index 100% rename from src/common/depCore.h rename to src/common/dep_core.h diff --git a/src/common/log.h b/src/common/log.h index 07afdb39d04f2bf3ba083f79e812fb951a6194be..a3cefe2541e310897ce753b8eb69711242762122 100644 --- a/src/common/log.h +++ b/src/common/log.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #ifdef PADDLE_MOBILE_DEBUG +#include #include #include #include @@ -115,26 +116,29 @@ struct ToLog { Print printer_; }; -#define LOG(level) \ - if (level > paddle_mobile::log_level) { \ - } else \ - paddle_mobile::ToLog( \ - level, \ - (std::stringstream() \ - << "[file: " \ - << (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : __FILE__) \ - << "] [line: " << __LINE__ << "] ") \ - .str()) - -#define DLOG \ - if (paddle_mobile::kLOG_DEBUG > paddle_mobile::log_level) { \ - } else \ - paddle_mobile::ToLog( \ - paddle_mobile::kLOG_DEBUG, \ - (std::stringstream() \ - << "[file: " \ - << (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : __FILE__) \ - << "] [line: " << __LINE__ << "] ") \ +#define LOG(level) \ + if (level > paddle_mobile::log_level) { \ + } else \ + paddle_mobile::ToLog( \ + level, static_cast( \ + std::stringstream() \ + << "[file: " \ + << (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) \ + : __FILE__) \ + << "] [line: " << __LINE__ << "] ") \ + .str()) + +#define DLOG \ + if (paddle_mobile::kLOG_DEBUG > paddle_mobile::log_level) { \ + } else \ + paddle_mobile::ToLog( \ + paddle_mobile::kLOG_DEBUG, \ + static_cast( \ + std::stringstream() \ + << "[file: " \ + << (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) \ + : __FILE__) \ + << "] [line: " << __LINE__ << "] ") \ .str()) #define LOGF(level, format, ...) \ diff --git a/src/common/type_define.h b/src/common/type_define.h index c26cdd91e0694d44cca9443503d3e263ee21f201..389f9a715f8cec3f0b494ae3b43b3952e49677f8 100644 --- a/src/common/type_define.h +++ b/src/common/type_define.h @@ -12,8 +12,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#pragma once; +#pragma once +#include #include #include #include diff --git a/src/common/types.h b/src/common/types.h index 30a0663eeef899e3b8ff35bcb062824417362efc..49f0c49a585ac45cbb0a061f72e33f2fb579a82e 100644 --- a/src/common/types.h +++ b/src/common/types.h @@ -12,10 +12,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#pragma once; +#pragma once #include #include +#include namespace paddle_mobile { enum class Precision : int { FP32 = 0 }; diff --git a/src/framework/attribute.h b/src/framework/attribute.h index 3b6608cf03e7f786ad8c087dc869516cb6220edb..478fc1b3f5ae95d9720b057d3ab0d2e8912e7093 100644 --- a/src/framework/attribute.h +++ b/src/framework/attribute.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include +#include #include #include diff --git a/src/framework/ddim.h b/src/framework/ddim.h index c1d917dff612de3a42168c47d0bacd3ac7bdd3ad..ff94c24adac5bea1fd4c7a80857b212056c06d36 100644 --- a/src/framework/ddim.h +++ b/src/framework/ddim.h @@ -15,6 +15,7 @@ limitations under the License. */ #pragma once #include +#include #include #include "common/enforce.h" #include "common/variant.h" diff --git a/src/framework/lod_tensor.cpp b/src/framework/lod_tensor.cpp index 0a57d29a0c05c009299d43b3b9f5a59b2c3dc341..e165e55507ed04a9b63e4ad5eb002f206c71d96c 100644 --- a/src/framework/lod_tensor.cpp +++ b/src/framework/lod_tensor.cpp @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "lod_tensor.h" +#include namespace paddle_mobile { namespace framework { diff --git a/src/framework/program/block_desc.cpp b/src/framework/program/block_desc.cpp index 4b45ab305bf0f353f017674773b5fc51203bfef8..4e3eb79d07d0c8c363a6c3a9556cf718ebdc08f2 100644 --- a/src/framework/program/block_desc.cpp +++ b/src/framework/program/block_desc.cpp @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "block_desc.h" +#include namespace paddle_mobile { namespace framework { diff --git a/src/framework/program/program-optimize/node.cpp b/src/framework/program/program-optimize/node.cpp index 4ea45ec0a859ef8aa3ab4e34de8279e732706803..89385e12d9c5f20a21f6ee6f3987c088c4b15563 100644 --- a/src/framework/program/program-optimize/node.cpp +++ b/src/framework/program/program-optimize/node.cpp @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "framework/program/program-optimize/node.h" +#include #include "framework/operator.h" namespace paddle_mobile { diff --git a/src/framework/program/program-optimize/program_optimize.cpp b/src/framework/program/program-optimize/program_optimize.cpp index e9b5cc5187bef7c9963e23b05187c09e2c789dc2..3619bc79f576651245aa322992df9d318c810cd4 100644 --- a/src/framework/program/program-optimize/program_optimize.cpp +++ b/src/framework/program/program-optimize/program_optimize.cpp @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "framework/program/program-optimize/program_optimize.h" +#include #include "framework/program/program-optimize/fusion_op_register.h" namespace paddle_mobile { diff --git a/src/framework/scope.cpp b/src/framework/scope.cpp index 2f7ff247b846f0a5f3e59c5c2f317a59598fc643..a1f5789aa52d2a70f54cef5c622c3a15907a4683 100644 --- a/src/framework/scope.cpp +++ b/src/framework/scope.cpp @@ -14,6 +14,7 @@ limitations under the License. */ #include "framework/scope.h" +#include #include #include #include diff --git a/src/io/io.cpp b/src/io/io.cpp index c7f8f174ac825463f66fd50b72e0c58d50bd537e..8b1577b0ee16b5a4e54fa2bcfc14abaa6497b699 100644 --- a/src/io/io.cpp +++ b/src/io/io.cpp @@ -13,6 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ #include "io/io.h" +#include #include #include "common/enforce.h" #include "common/log.h" @@ -25,7 +26,6 @@ limitations under the License. */ #include "framework/scope.h" #include "framework/tensor.h" #ifdef PADDLE_EXECUTOR_MULTITHREAD -#include #include #include #include "common/threadpool.h" diff --git a/src/io/io.h b/src/io/io.h index ff520dd628406eae47f76196dbe66a0992dfe735..acae829339bdc049c5899b9c7f6a7a2c91693ae8 100644 --- a/src/io/io.h +++ b/src/io/io.h @@ -27,7 +27,7 @@ limitations under the License. */ #include #include #include -#include "common/depCore.h" +#include "common/dep_core.h" #endif namespace paddle_mobile { diff --git a/src/memory/t_malloc.cpp b/src/memory/t_malloc.cpp index 62e929024d7232ba4bee6b9e95ee895c2badb95e..0252f3c07c06487720586b0f650e2179d247234f 100644 --- a/src/memory/t_malloc.cpp +++ b/src/memory/t_malloc.cpp @@ -12,8 +12,6 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -#pragma once - #include "memory/t_malloc.h" #include #include diff --git a/src/operators/kernel/arm/batchnorm_kernel.cpp b/src/operators/kernel/arm/batchnorm_kernel.cpp index ecebc009bc36542f54578c881716d5fa92c04b7b..964bf71f451e2ca48d3742ed5151e9784c516d5c 100644 --- a/src/operators/kernel/arm/batchnorm_kernel.cpp +++ b/src/operators/kernel/arm/batchnorm_kernel.cpp @@ -14,8 +14,6 @@ limitations under the License. */ #ifdef BATCHNORM_OP -#pragma once - #include "operators/kernel/batchnorm_kernel.h" #include "operators/kernel/central-arm-func/batchnorm_arm_func.h" diff --git a/src/operators/kernel/arm/box_coder_kernel.cpp b/src/operators/kernel/arm/box_coder_kernel.cpp index 02ec85a444c380ba76d64b0d15d35ce27b9eaf44..df0a75f357658736ede4265a6cc57db30afee1d4 100644 --- a/src/operators/kernel/arm/box_coder_kernel.cpp +++ b/src/operators/kernel/arm/box_coder_kernel.cpp @@ -15,6 +15,7 @@ limitations under the License. */ #ifdef BOXCODER_OP #include "operators/kernel/box_coder_kernel.h" +#include namespace paddle_mobile { namespace operators { diff --git a/src/operators/kernel/arm/multiclass_nms_kernel.cpp b/src/operators/kernel/arm/multiclass_nms_kernel.cpp index 58f224ab536173fff46bb1739b27590382fbab6d..67cf8197ca4c3113fc4fde3d493d6ed209221b59 100644 --- a/src/operators/kernel/arm/multiclass_nms_kernel.cpp +++ b/src/operators/kernel/arm/multiclass_nms_kernel.cpp @@ -14,10 +14,8 @@ limitations under the License. */ #ifdef MULTICLASSNMS_OP -#pragma once - #include "operators/kernel/multiclass_nms_kernel.h" - +#include namespace paddle_mobile { namespace operators { diff --git a/src/operators/kernel/arm/prior_box_kernel.cpp b/src/operators/kernel/arm/prior_box_kernel.cpp index c14a143ce5d98749c95c780941966944e9ca1249..13939bc7bf27904405677560f17d2e0b85748310 100644 --- a/src/operators/kernel/arm/prior_box_kernel.cpp +++ b/src/operators/kernel/arm/prior_box_kernel.cpp @@ -14,8 +14,6 @@ limitations under the License. */ #ifdef PRIORBOX_OP -#pragma once - #include "operators/kernel/prior_box_kernel.h" namespace paddle_mobile { diff --git a/src/operators/kernel/arm/relu_kernel.cpp b/src/operators/kernel/arm/relu_kernel.cpp index 8ec0bfc4fa0c5762418efbd18cda664a1ec43271..5bc485b77a8fac9379adbd1a3bd4d406e5a82fcb 100644 --- a/src/operators/kernel/arm/relu_kernel.cpp +++ b/src/operators/kernel/arm/relu_kernel.cpp @@ -14,8 +14,6 @@ limitations under the License. */ #ifdef RELU_OP -#pragma once - #include "operators/kernel/relu_kernel.h" #include diff --git a/src/operators/kernel/arm/reshape_kernel.cpp b/src/operators/kernel/arm/reshape_kernel.cpp index 8e40dcc987f52265824325af94aa45a1dbdbdb74..97364f9a3f7ce9fe8da5814ad2a483f858938bbf 100644 --- a/src/operators/kernel/arm/reshape_kernel.cpp +++ b/src/operators/kernel/arm/reshape_kernel.cpp @@ -14,8 +14,6 @@ limitations under the License. */ #ifdef RESHAPE_OP -#pragma once - #include "operators/kernel/reshape_kernel.h" namespace paddle_mobile { diff --git a/src/operators/kernel/arm/sigmoid_kernel.cpp b/src/operators/kernel/arm/sigmoid_kernel.cpp index 3f256c69c2ba04de97bb443770c2b460046028e9..3e87bfacc5335e52ecdcb0b917f5826b80449ef4 100644 --- a/src/operators/kernel/arm/sigmoid_kernel.cpp +++ b/src/operators/kernel/arm/sigmoid_kernel.cpp @@ -18,7 +18,7 @@ limitations under the License. */ #if __ARM_NEON #include "../../math/math_func_neon.h" #endif - +#include namespace paddle_mobile { namespace operators { diff --git a/src/operators/kernel/lrn_kernel.h b/src/operators/kernel/lrn_kernel.h index 3b4b34250ef376032299bf14b2d4e2074e46245d..40c48b3663c6825e03028439725c428ce048d254 100644 --- a/src/operators/kernel/lrn_kernel.h +++ b/src/operators/kernel/lrn_kernel.h @@ -14,10 +14,11 @@ limitations under the License. */ #ifdef LRN_OP -#pragma once #include "framework/operator.h" #include "operators/op_param.h" +#include + #ifdef __ARM_NEON #include "arm_neon.h" #include "operators/math/math_func_neon.h" diff --git a/src/operators/kernel/mali/batchnorm_kernel.cpp b/src/operators/kernel/mali/batchnorm_kernel.cpp index 08e3642614e99574ed78cd538e1ef6ccd2ab7603..ff27afc71c42ed1c2b7e67eefbdadd86e92cc0fc 100644 --- a/src/operators/kernel/mali/batchnorm_kernel.cpp +++ b/src/operators/kernel/mali/batchnorm_kernel.cpp @@ -14,8 +14,6 @@ limitations under the License. */ #ifdef BATCHNORM_OP -#pragma once - #include "operators/kernel/batchnorm_kernel.h" #ifdef PADDLE_MOBILE_MALI_GPU #include "acl_operator.h" diff --git a/src/operators/kernel/prior_box_kernel.h b/src/operators/kernel/prior_box_kernel.h index be13f0fc16c0c0c0b16117a46b80a9f9acdeffae..79fc630b8efb50dec1ff336d2b66d5094eaeb5a5 100644 --- a/src/operators/kernel/prior_box_kernel.h +++ b/src/operators/kernel/prior_box_kernel.h @@ -16,8 +16,9 @@ limitations under the License. */ #pragma once +#include +#include #include - #include "framework/operator.h" #include "operators/math/transform.h" #include "operators/op_param.h" diff --git a/src/operators/math/pool_3x3.cpp b/src/operators/math/pool_3x3.cpp index f404b644d78cb1b94eb96a2d587fead2575b3814..0259565377386a1415d27b0794580a6a223a88d4 100644 --- a/src/operators/math/pool_3x3.cpp +++ b/src/operators/math/pool_3x3.cpp @@ -19,7 +19,7 @@ limitations under the License. */ #if __ARM_NEON #include #endif // __ARM_NEON - +#include namespace paddle_mobile { namespace operators { namespace math { diff --git a/tools/arm-platform.cmake b/tools/arm-platform.cmake new file mode 100644 index 0000000000000000000000000000000000000000..9f2b6d5e89d92255848af54321ea09ebdb058691 --- /dev/null +++ b/tools/arm-platform.cmake @@ -0,0 +1,9 @@ + +set(ARCH "armv7-a") + +set(FLOAT_ABI "softfp" CACHE STRING "-mfloat-api chosen") +set_property(CACHE FLOAT_ABI PROPERTY STRINGS "softfp" "soft" "hard") + +set(FPU "neon") + +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${ARCH} -mfloat-abi=${FLOAT_ABI} -mfpu=${FPU}") diff --git a/tools/op.cmake b/tools/op.cmake new file mode 100644 index 0000000000000000000000000000000000000000..2eabac925f6021448243b3668c22cbcaebe2f1d9 --- /dev/null +++ b/tools/op.cmake @@ -0,0 +1,148 @@ +set(NET "googlenet" CACHE STRING "select net type") +set_property(CACHE NET PROPERTY STRINGS "defult" "googlenet" "mobilenet" "yolo" "squeezenet") + +if (NET EQUAL "googlenet") + set(CONCAT_OP ON) + set(CONV_OP ON) + set(LRN_OP ON) + set(MUL_OP ON) + set(ELEMENTWISEADD_OP ON) + set(FUSION_FC_OP ON) + set(POOL_OP ON) + set(RELU_OP ON) + set(FUSION_CONVADD_OP ON) + set(FUSION_CONVADD_RELU_OP ON) +elseif (NET EQUAL "mobilenet") + set(CONV_OP ON) + set(ELEMENTWISEADD_OP ON) + set(RELU_OP ON) + set(SOFTMAX_OP ON) + set(SOFTMAX_OP ON) + set(DEPTHWISECONV_OP ON) + set(BATCHNORM_OP ON) + set(POOL_OP ON) + set(RESHAPE_OP ON) +elseif (NET EQUAL "yolo") + set(BATCHNORM_OP ON) + set(CONV_OP ON) + set(RELU_OP ON) + set(ELEMENTWISEADD_OP ON) +elseif (NET EQUAL "squeezenet") + set(CONCAT_OP ON) + set(CONV_OP ON) + set(RELU_OP ON) + set(ELEMENTWISEADD_OP ON) + set(POOL_OP ON) + set(RESHAPE_OP ON) + set(SOFTMAX_OP ON) +elseif (NET EQUAL "resnet") + set(CONV_OP ON) + set(BATCHNORM_OP ON) + set(ELEMENTWISEADD_OP ON) + set(SOFTMAX_OP ON) + set(MUL_OP ON) + set(POOL_OP ON) + set(RELU_OP ON) +else () + set(BATCHNORM_OP ON) + set(BOXCODER_OP ON) + set(CONCAT_OP ON) + set(CONV_OP ON) + set(DEPTHWISECONV_OP ON) + set(ELEMENTWISEADD_OP ON) + set(FUSION_CONVADD_OP ON) + set(CONVADDRELU_OP ON) + set(FUSION_FC_OP ON) + set(LRN_OP ON) + set(MUL_OP ON) + set(MULTICLASSNMS_OP ON) + set(POOL_OP ON) + set(PRIORBOX_OP ON) + set(RELU_OP ON) + set(RESHAPE_OP ON) + set(SIGMOID_OP ON) + set(SOFTMAX_OP ON) + set(TRANSPOSE_OP ON) + set(FUSION_CONVADD_RELU_OP ON) + # option(BATCHNORM_OP "" ON) + # option(BOXCODER_OP "" ON) + # option(CONCAT_OP "" ON) + # option(CONV_OP "" ON) + # option(DEPTHWISECONV_OP "" ON) + # option(ELEMENTWISEADD_OP "" ON) + # option(FUSION_CONVADD_OP "" ON) + # option(CONVADDRELU_OP "" ON) + # option(FUSION_FC_OP "" ON) + # option(LRN_OP "" ON) + # option(MUL_OP "" ON) + # option(MULTICLASSNMS_OP "" ON) + # option(POOL_OP "" ON) + # option(PRIORBOX_OP "" ON) + # option(RELU_OP "" ON) + # option(RESHAPE_OP "" ON) + # option(SIGMOID_OP "" ON) + # option(SOFTMAX_OP "" ON) + # option(TRANSPOSE_OP "" ON) + # option(FUSION_CONVADD_RELU_OP "" ON) +endif () + +if (BATCHNORM_OP) + add_definitions(-DBATCHNORM_OP) +endif() +if (BOXCODER_OP) + add_definitions(-DBOXCODER_OP) +endif() +if (CONCAT_OP) + add_definitions(-DCONCAT_OP) +endif() +if (CONV_OP) + add_definitions(-DCONV_OP) +endif() +if (DEPTHWISECONV_OP) + add_definitions(-DDEPTHWISECONV_OP) +endif() +if (ELEMENTWISEADD_OP) + add_definitions(-DELEMENTWISEADD_OP) +endif() +if (FUSION_CONVADD_OP) + add_definitions(-DFUSION_CONVADD_OP) +endif() +if (CONVADDRELU_OP) + add_definitions(-DCONVADDRELU_OP) +endif() +if (FUSION_FC_OP) + add_definitions(-DFUSION_FC_OP) +endif() +if (LRN_OP) + add_definitions(-DLRN_OP) +endif() +if (MUL_OP) + add_definitions(-DMUL_OP) +endif() +if (MULTICLASSNMS_OP) + add_definitions(-DMULTICLASSNMS_OP) +endif() +if (POOL_OP) + add_definitions(-DPOOL_OP) +endif() +if (PRIORBOX_OP) + add_definitions(-DPRIORBOX_OP) +endif() +if (RELU_OP) + add_definitions(-DRELU_OP) +endif() +if (RESHAPE_OP) + add_definitions(-DRESHAPE_OP) +endif() +if (SIGMOID_OP) + add_definitions(-DSIGMOID_OP) +endif() +if (SOFTMAX_OP) + add_definitions(-DSOFTMAX_OP) +endif() +if (TRANSPOSE_OP) + add_definitions(-DTRANSPOSE_OP) +endif() +if (FUSION_CONVADD_RELU_OP) + add_definitions(-DFUSION_CONVADD_RELU_OP) +endif() \ No newline at end of file diff --git a/tools/toolchains/arm-android-neon.cmake b/tools/toolchains/arm-android-neon.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f2fa600b90fb54886838e953e61c1e940569dee6 --- /dev/null +++ b/tools/toolchains/arm-android-neon.cmake @@ -0,0 +1,2 @@ +set(ANDROID_ARM_NEON ON) +include("${CMAKE_CURRENT_LIST_DIR}/../android-cmake/android.toolchain.cmake") \ No newline at end of file diff --git a/tools/toolchains/arm-linux-gnueabi.cmake b/tools/toolchains/arm-linux-gnueabi.cmake new file mode 100644 index 0000000000000000000000000000000000000000..ee3cb50796d184f9f4577e8aabb4cf0ca98c955f --- /dev/null +++ b/tools/toolchains/arm-linux-gnueabi.cmake @@ -0,0 +1,16 @@ +# CMake toolchain file for building ARM software on Linux environment + +set(CMAKE_SYSTEM_NAME Linux) +set(CMAKE_SYSTEM_VERSION 1) + +set(CMAKE_C_COMPILER /usr/bin/arm-linux-gnueabi-gcc) +set(CMAKE_CXX_COMPILER /usr/bin/arm-linux-gnueabi-g++) +set(CMAKE_STRIP /usr/bin/arm-linux-gnueabi-strip) + +set(CMAKE_FIND_ROOT_PATH /usr/arm-linux-gnueabi) + +set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) +set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) +set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) + +include("${CMAKE_CURRENT_LIST_DIR}/../arm-platform.cmake")