diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c3ff01e5d3e20923021904cdbe9008a11cc30ce..14e8126f026008ff87b6dc524b20f4f9f8e17c52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,41 +6,38 @@ 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" ON) -option(MALI_GPU "mali gpu" ON) +option(CPU "armv7 with neon" ON) +option(MALI_GPU "mali gpu" OFF) option(FPGA "fpga" OFF) if (CPU) - add_definitions(-DPADDLE_MOBILE_CPU) + add_definitions(-DPADDLE_MOBILE_CPU) endif() if (MALI_GPU) - add_definitions(-DPADDLE_MOBILE_MALI_GPU) + add_definitions(-DPADDLE_MOBILE_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 "${CMAKE_CXX_FLAGS}") -else() - set(CMAKE_BUILD_TYPE Release) -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") + 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) + add_definitions(-fvisibility=hidden -fvisibility-inlines-hidden) +endif () if (USE_EXCEPTION) message(STATUS "use exception") @@ -54,110 +51,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..39fbb34ee8f62df1079b658993a2be6ef71bdc56 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,27 +1,32 @@ -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 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 diff --git a/src/common/log.h b/src/common/log.h index 07afdb39d04f2bf3ba083f79e812fb951a6194be..4257147635717d0795dcc84641e1a224f399b506 100644 --- a/src/common/log.h +++ b/src/common/log.h @@ -18,6 +18,7 @@ limitations under the License. */ #ifdef PADDLE_MOBILE_DEBUG #include #include +#include #include #endif #ifdef ANDROID @@ -120,7 +121,7 @@ struct ToLog { } else \ paddle_mobile::ToLog( \ level, \ - (std::stringstream() \ + static_cast(std::stringstream() \ << "[file: " \ << (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : __FILE__) \ << "] [line: " << __LINE__ << "] ") \ @@ -131,7 +132,7 @@ struct ToLog { } else \ paddle_mobile::ToLog( \ paddle_mobile::kLOG_DEBUG, \ - (std::stringstream() \ + static_cast(std::stringstream() \ << "[file: " \ << (strrchr(__FILE__, '/') ? (strrchr(__FILE__, '/') + 1) : __FILE__) \ << "] [line: " << __LINE__ << "] ") \ diff --git a/src/common/type_define.h b/src/common/type_define.h index c26cdd91e0694d44cca9443503d3e263ee21f201..269c58d769477d54e724bf5baf786c59b1219bcf 100644 --- a/src/common/type_define.h +++ b/src/common/type_define.h @@ -12,11 +12,12 @@ 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 #include "framework/attribute.h" #include "framework/scope.h" 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/common/workThread.h b/src/common/workThread.h new file mode 100644 index 0000000000000000000000000000000000000000..a6d52de810a96ede0e2b8d5f7831b409d84c5f52 --- /dev/null +++ b/src/common/workThread.h @@ -0,0 +1,71 @@ +#pragma once + +#include +#include +#include +#include +// #include +// #include + +template +class workThread { +public: + void init(std::vector & ops) { + this->ops = ops; + t = std::thread([this]{ + threadLoop(); + }); + } + void threadLoop() { + //std::unique_lock lk(m); + for (;;) { + while(true) { + std::lock_guard lg(m); + if (job != -1) break; + }; + // std::cout << "loop!" << "\n"; + // cv.wait(lk, [this]{ + // // std::cout << "wake up!!! you have work to do: " << job << "\n"; + // return job != -1; + // }); + if (job == -2) { + break; + } + // TODO run job + ops[job]->Run(); + job = -1; + cv.notify_one(); + } + } + void run(int i) { + std::lock_guard lk(m); + job = i; + cv.notify_one(); + } + void join() { + std::unique_lock lk(m); + cv.wait(lk, [this]{ + return job == -1; + }); + } + void quit() { + { + std::cout << "try get lock!!!\n"; + std::lock_guard lk(m); + std::cout << "set job = -2\n"; + job = -2; + cv.notify_one(); + } + t.join(); + std::cout << "job quit\n"; + } +private: + std::vector ops; + // std::queue> q; + int job = -1; + // std::atomic job; + std::condition_variable cv; + std::mutex m; + std::thread t; + // bool idle = false; +}; diff --git a/src/common/workThread2.h b/src/common/workThread2.h new file mode 100644 index 0000000000000000000000000000000000000000..52643872c2acb4d106327ebb42a7d553407023e6 --- /dev/null +++ b/src/common/workThread2.h @@ -0,0 +1,73 @@ +#pragma once + +#include +#include +#include +#include +// #include +// #include + +template +class workThread { +public: + void init() { + // this->ops = ops; + t = std::thread([this]{ + threadLoop(); + }); + } + void threadLoop() { + //std::unique_lock lk(m); + for (;;) { + while(true) { + std::lock_guard lg(m); + if (job != -1) break; + }; + // std::cout << "loop!" << "\n"; + // cv.wait(lk, [this]{ + // // std::cout << "wake up!!! you have work to do: " << job << "\n"; + // return job != -1; + // }); + if (job == -2) { + break; + } + // TODO run job + this->f(); + job = -1; + cv.notify_one(); + } + } + template + void run(Func && f) { + std::lock_guard lk(m); + this->f = std::forward(f); + job = 1; + cv.notify_one(); + } + + void join() { + std::unique_lock lk(m); + cv.wait(lk, [this]{ + return job == -1; + }); + } + void quit() { + { + std::cout << "try get lock!!!\n"; + std::lock_guard lk(m); + std::cout << "set job = -2\n"; + job = -2; + cv.notify_one(); + } + t.join(); + std::cout << "job quit\n"; + } +private: + std::function f; + int job = -1; + // std::atomic job; + std::condition_variable cv; + std::mutex m; + std::thread t; + // bool idle = false; +}; diff --git a/src/framework/attribute.h b/src/framework/attribute.h index 3b6608cf03e7f786ad8c087dc869516cb6220edb..30cf6a1d0cafc52cbd945b6b633fc4970f2a420b 100644 --- a/src/framework/attribute.h +++ b/src/framework/attribute.h @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include +#include #include "common/enforce.h" #include "common/log.h" diff --git a/src/framework/ddim.h b/src/framework/ddim.h index c1d917dff612de3a42168c47d0bacd3ac7bdd3ad..dea6c9d45be7b235f44ba957a4206518dd53aa0e 100644 --- a/src/framework/ddim.h +++ b/src/framework/ddim.h @@ -16,6 +16,7 @@ limitations under the License. */ #include #include +#include #include "common/enforce.h" #include "common/variant.h" #include "dim.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/profile.cpp b/src/framework/profile.cpp new file mode 100644 index 0000000000000000000000000000000000000000..a8c65feed0b048d514c8a9223f683863d7f788bc --- /dev/null +++ b/src/framework/profile.cpp @@ -0,0 +1,20 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +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. */ + +// #include "profile.h" + +// Profile & getProfile() { +// static Profile p; +// return p; +// } \ No newline at end of file diff --git a/src/framework/profile.h b/src/framework/profile.h new file mode 100644 index 0000000000000000000000000000000000000000..0648ae5cc8dd8e41c9cb6433811d7d5aed0c6401 --- /dev/null +++ b/src/framework/profile.h @@ -0,0 +1,33 @@ +/* Copyright (c) 2018 PaddlePaddle Authors. All Rights Reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +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 "framework/program/program.h" + +// class Profile { +// public: +// template +// void init(const framework::Program &); +// // getDotDesc(); +// // getTimelineInfo(); +// private: +// struct OpInfo { +// int index; +// std::shared_ptr op; +// }; +// std::unordered_map opInfo; +// }; + +// Profile & getProfile(); 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..d84033b936a713ffba86d81a467925fddb2e6b4a 100644 --- a/src/framework/program/program-optimize/node.cpp +++ b/src/framework/program/program-optimize/node.cpp @@ -14,6 +14,7 @@ limitations under the License. */ #include "framework/program/program-optimize/node.h" #include "framework/operator.h" +#include 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..223421c23cc6feb0707d5bd8cfe1414ea9e9b6bc 100644 --- a/src/framework/program/program-optimize/program_optimize.cpp +++ b/src/framework/program/program-optimize/program_optimize.cpp @@ -14,6 +14,7 @@ limitations under the License. */ #include "framework/program/program-optimize/program_optimize.h" #include "framework/program/program-optimize/fusion_op_register.h" +#include namespace paddle_mobile { diff --git a/src/framework/scope.cpp b/src/framework/scope.cpp index 2f7ff247b846f0a5f3e59c5c2f317a59598fc643..7324cf9a2eb69829d069381971c7a1a6439113be 100644 --- a/src/framework/scope.cpp +++ b/src/framework/scope.cpp @@ -17,6 +17,7 @@ limitations under the License. */ #include #include #include +#include namespace paddle_mobile { namespace framework { diff --git a/src/io/io.cpp b/src/io/io.cpp index 7931432bd1d4528ab9b0cda7ab05ab13c14dfcfe..ca37644d6f88bd5664d1eed4ffd508d607905305 100644 --- a/src/io/io.cpp +++ b/src/io/io.cpp @@ -24,8 +24,8 @@ limitations under the License. */ #include "framework/program/var_desc.h" #include "framework/scope.h" #include "framework/tensor.h" -#ifdef PADDLE_EXECUTOR_MULTITHREAD #include +#ifdef PADDLE_EXECUTOR_MULTITHREAD #include #include #include "common/threadpool.h" 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 cb30fb41e936543737cd48717920c6a62fb19033..21787bcbe8c0ae8d75d86aaaabca950844df4950 100644 --- a/src/operators/kernel/arm/batchnorm_kernel.cpp +++ b/src/operators/kernel/arm/batchnorm_kernel.cpp @@ -14,9 +14,9 @@ limitations under the License. */ #ifdef BATCHNORM_OP -#pragma once #include "operators/kernel/batchnorm_kernel.h" +#include namespace paddle_mobile { namespace operators { diff --git a/src/operators/kernel/arm/box_coder_kernel.cpp b/src/operators/kernel/arm/box_coder_kernel.cpp index 9654228911af77e751e4ef9d1b92fb92ae30591d..87f3056514198d97b60e3acc6980681e2545e857 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 39f55dab38031db14b617e48eedb236eacd1b714..b1dc5cc65fd2cb658979302516d2dc34807220a5 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 e029c555d4d40745976be45b7a9c022eb62705c7..c476db137a494f722c801e1f6dfaef120b0fdf4b 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 86bf53e5a1e5ecc285c9e9f20cb412d290d535d1..63d332e3eee835256bd404baabf0fb023ca183c1 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 3d40309e97145e1df70f2a4191ee571c4a05627a..206eb3df379dc6d4522b36686666a9de8829b71a 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 20f275ff482d7073195d075c374e4a0969993714..b4c30e2eb86d72365fdbba6188ac60a491e327b0 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 d92d15e5e9d22c431799e924ef1b5ba0de840004..595a2caa3e7aa99afe7636a644f8eba5ddb41357 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 5ad6d6f015c9d8ec095f8269642dd72f4d0a56a1..4abc3cad0562af8b8f5964e342a96717f1316dec 100644 --- a/src/operators/kernel/mali/batchnorm_kernel.cpp +++ b/src/operators/kernel/mali/batchnorm_kernel.cpp @@ -14,7 +14,6 @@ limitations under the License. */ #ifdef BATCHNORM_OP -#pragma once #include "operators/kernel/batchnorm_kernel.h" diff --git a/src/operators/kernel/prior_box_kernel.h b/src/operators/kernel/prior_box_kernel.h index 3e7c72a736ea56beb6cede1d5892675d6721163f..f1b3a6f8d9a6c1448c31e909a59ba54a724442c4 100644 --- a/src/operators/kernel/prior_box_kernel.h +++ b/src/operators/kernel/prior_box_kernel.h @@ -17,7 +17,8 @@ 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/android-arm-neon.cmake b/tools/toolchains/android-arm-neon.cmake new file mode 100644 index 0000000000000000000000000000000000000000..f2fa600b90fb54886838e953e61c1e940569dee6 --- /dev/null +++ b/tools/toolchains/android-arm-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..71e54edd08473e3cbf79f206187d80a01010b2fd --- /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")