未验证 提交 a29a9b4d 编写于 作者: H Houjiang Chen 提交者: GitHub

Merge pull request #1403 from hjchen2/ci_build

Fix compile warning, disable openmp for ios ci build, update jni load api
......@@ -175,11 +175,8 @@ struct Print {
friend struct ToLog;
template <typename T>
Print &operator<<(T const &value) {
Print p = Print();
return p;
return *this;
}
private:
};
struct ToLog {
......
......@@ -39,7 +39,7 @@ using framework::Tensor;
using paddle_mobile::CPU;
using std::string;
extern const char *ANDROID_LOG_TAG =
const char *ANDROID_LOG_TAG =
"paddle_mobile LOG built on " __DATE__ " " __TIME__;
paddle_mobile::PaddleMobile<paddle_mobile::CPU> paddle_mobile;
static std::mutex shared_mutex;
......@@ -53,25 +53,25 @@ string jstring2cppstring(JNIEnv *env, jstring jstr) {
return cppstr;
}
JNIEXPORT jboolean JNICALL Java_com_baidu_paddle_PML_load(JNIEnv *env,
jclass thiz,
jstring modelPath) {
JNIEXPORT jboolean JNICALL Java_com_baidu_paddle_PML_load(
JNIEnv *env, jclass thiz, jstring modelPath, jboolean lod_mode = false) {
std::lock_guard<std::mutex> lock(shared_mutex);
ANDROIDLOGI("load invoked");
bool optimize = true;
bool isLoadOk = false;
#ifdef ENABLE_EXCEPTION
try {
isLoadOk = getPaddleMobileInstance()->Load(
jstring2cppstring(env, modelPath), optimize);
jstring2cppstring(env, modelPath), optimize, false, 1,
static_cast<bool>(lod_mode));
} catch (paddle_mobile::PaddleMobileException &e) {
ANDROIDLOGE("jni got an PaddleMobileException! ", e.what());
isLoadOk = false;
}
#else
isLoadOk = getPaddleMobileInstance()->Load(jstring2cppstring(env, modelPath),
optimize);
optimize, false, 1,
static_cast<bool>(lod_mode));
#endif
return static_cast<jboolean>(isLoadOk);
}
......
......@@ -26,7 +26,8 @@ namespace jni {
*/
JNIEXPORT jboolean JNICALL Java_com_baidu_paddle_PML_load(JNIEnv *env,
jclass thiz,
jstring modelPath);
jstring modelPath,
jboolean lod_mode);
/**
* load separated qualified model for android
......@@ -64,6 +65,9 @@ JNIEXPORT jfloatArray JNICALL Java_com_baidu_paddle_PML_predictYuv(
JNIEXPORT jfloatArray JNICALL
Java_com_baidu_paddle_PML_predict(JNIEnv *env, jclass thiz, jfloatArray buf);
JNIEXPORT jlongArray JNICALL
Java_com_baidu_paddle_PML_predictLod(JNIEnv *env, jclass thiz, jlongArray buf);
/**
* setThreadCount for multithread
*/
......
......@@ -15,7 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVADDBNRELU_OP
#include "operators/kernel/conv_add_bn_relu_kernel.h"
#include <math.h>
#include <cmath>
#include "operators/kernel/central-arm-func/conv_add_bn_relu_arm_func.h"
namespace paddle_mobile {
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVBNADDRELU_OP
#include "operators/kernel/conv_bn_add_relu_kernel.h"
#include <cmath>
#include "operators/kernel/central-arm-func/conv_bn_add_relu_arm_func.h"
namespace paddle_mobile {
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVBNRELU_OP
#include "operators/kernel/conv_bn_relu_kernel.h"
#include <cmath>
#include "operators/kernel/central-arm-func/conv_bn_relu_arm_func.h"
namespace paddle_mobile {
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_DWCONVBNRELU_OP
#include "operators/kernel/dwconv_bn_relu_kernel.h"
#include <cmath>
#include "operators/kernel/central-arm-func/dwconv_bn_relu_arm_func.h"
namespace paddle_mobile {
......
......@@ -167,7 +167,7 @@ float find_abs_max(const Tensor *input) {
max_abs = vmaxvq_f32(__max);
#endif
for (size_t i = 0; i < remain; ++i) {
max_abs = std::max(max_abs, std::abs(x[i]));
max_abs = std::max(max_abs, fabs(x[i]));
}
return max_abs;
}
......
......@@ -21,6 +21,7 @@ limitations under the License. */
#include "operators/math/gemm.h"
#include "operators/math/math_function.h"
#include "operators/op_param.h"
namespace paddle_mobile {
namespace operators {
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef BATCHNORM_OP
#include "operators/kernel/batchnorm_kernel.h"
#include <cmath>
namespace paddle_mobile {
namespace operators {
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVADDBNRELU_OP
#include "operators/kernel/conv_add_bn_relu_kernel.h"
#include <cmath>
#include "framework/cl/cl_image.h"
#include "framework/cl/cl_tool.h"
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVBNADDRELU_OP
#include "operators/kernel/conv_bn_add_relu_kernel.h"
#include <cmath>
namespace paddle_mobile {
namespace operators {
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVBNRELU_OP
#include "operators/kernel/conv_bn_relu_kernel.h"
#include <cmath>
namespace paddle_mobile {
namespace operators {
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_DWCONVBNRELU_OP
#include "operators/kernel/dwconv_bn_relu_kernel.h"
#include <cmath>
namespace paddle_mobile {
namespace operators {
......
......@@ -15,7 +15,8 @@ limitations under the License. */
#ifdef FUSION_CONVADDBN_OP
#include "operators/kernel/conv_add_bn_kernel.h"
#include <math.h>
#include <cmath>
namespace paddle_mobile {
namespace operators {
......
......@@ -15,7 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVADDBNRELU_OP
#include "operators/kernel/conv_add_bn_relu_kernel.h"
#include <math.h>
#include <cmath>
namespace paddle_mobile {
namespace operators {
......
文件模式从 100755 更改为 100644
文件模式从 100755 更改为 100644
......@@ -22,7 +22,7 @@ namespace operators {
template <>
bool SoftmaxKernel<FPGA, float>::Init(SoftmaxParam<FPGA> *param) {
auto input = const_cast<Tensor *>(param->InputX());
auto input = const_cast<LoDTensor *>(param->InputX());
auto input_ptr = input->data<float>();
auto out = param->Out();
fpga::format_fp32_ofm(out);
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVADDBN_OP
#include "operators/kernel/conv_add_bn_kernel.h"
#include <cmath>
namespace paddle_mobile {
namespace operators {
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVADDBNRELU_OP
#include "operators/kernel/conv_add_bn_relu_kernel.h"
#include <cmath>
namespace paddle_mobile {
namespace operators {
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVBN_OP
#include "operators/kernel/conv_bn_kernel.h"
#include <cmath>
namespace paddle_mobile {
namespace operators {
......
......@@ -15,6 +15,7 @@ limitations under the License. */
#ifdef FUSION_CONVBNRELU_OP
#include "operators/kernel/conv_bn_relu_kernel.h"
#include <cmath>
#include "fpga/V2/filter.h"
namespace paddle_mobile {
......
......@@ -40,8 +40,8 @@ template <>
inline int8_t Round<ROUND_NEAREST_TO_EVEN>(const float &x) {
float v = std::round(x);
int32_t q = static_cast<int32_t>(v);
if (std::abs(std::abs(q - v) - 0.5) <= 0) {
if (std::abs(q) % 2 != 0) {
if (fabs(fabs(q - v) - 0.5) <= 0) {
if (abs(q) % 2 != 0) {
q = q + ((q > 0) ? -1 : 1);
}
}
......
......@@ -26,6 +26,7 @@ function print_usage() {
${BLUE}ios${NONE}: run build for apple ios platform
${BLUE}linux_armv7${NONE}: run build for linux armv7 platform
${BLUE}linux_armv8${NONE}: run build for linux armv8 platform
${BLUE}fpga${NONE}: run build for fpga platform
"
echo "\n${RED}Network${NONE}: optional, for deep compressing the framework size
${BLUE}googlenet${NONE}: build only googlenet support
......@@ -146,6 +147,7 @@ function build_ios_armv8_cpu_only() {
-DIOS_PLATFORM=OS \
-DIOS_ARCH="${IOS_ARCH}" \
-DIS_IOS=true \
-DUSE_OPENMP=OFF \
-DGPU_MALI=OFF \
-DGPU_CL=OFF \
-DFPGA=OFF
......@@ -163,6 +165,7 @@ function build_ios_armv8_gpu() {
-DIOS_PLATFORM=OS \
-DIOS_ARCH="${IOS_ARCH}" \
-DIS_IOS=true \
-DUSE_OPENMP=OFF \
-DGPU_MALI=OFF \
-DGPU_CL=ON \
-DFPGA=OFF
......@@ -217,11 +220,19 @@ function build_ios() {
}
function build_linux_armv7() {
check_ndk
build_linux_armv7_cpu_only
# build_linux_armv7_gpu
}
function build_linux_fpga() {
cd ..
image=`docker images paddle-mobile:dev | grep 'paddle-mobile'`
if [[ "x"$image == "x" ]]; then
docker build -t paddle-mobile:dev - < Dockerfile
fi
docker run --rm -v `pwd`:/workspace paddle-mobile:dev bash /workspace/tools/docker_build_fpga.sh
}
function main() {
local CMD=$1
init
......@@ -238,6 +249,9 @@ function main() {
linux_armv7)
build_linux_armv7
;;
fpga)
build_linux_fpga
;;
*)
print_usage
exit 0
......
apt-get update
apt-get install -y gcc g++ cmake
cd /workspace && mkdir build
cd build && cmake .. -DCPU=OFF -DFPGA=ON && make -j4
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册