diff --git a/src/common/log.h b/src/common/log.h index d964d9c1b39a7e72e3d757ef2be0737fd1d25f94..c5146533d16273e223cc123c132bd137410f48ac 100644 --- a/src/common/log.h +++ b/src/common/log.h @@ -175,11 +175,8 @@ struct Print { friend struct ToLog; template Print &operator<<(T const &value) { - Print p = Print(); - return p; + return *this; } - - private: }; struct ToLog { diff --git a/src/io/jni/paddle_mobile_jni.cpp b/src/io/jni/paddle_mobile_jni.cpp index 79283070034a4b0a2720cdfb7e68412041163053..66c3084d2ec473d55c1fcfdf6fd417d9eb24ac3d 100644 --- a/src/io/jni/paddle_mobile_jni.cpp +++ b/src/io/jni/paddle_mobile_jni.cpp @@ -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; 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 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(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(lod_mode)); #endif return static_cast(isLoadOk); } diff --git a/src/io/jni/paddle_mobile_jni.h b/src/io/jni/paddle_mobile_jni.h index 158d64d4517b69761b26fc18f2e0943798174014..313b3e5340409e9fdfb89062a76a2789160d44af 100644 --- a/src/io/jni/paddle_mobile_jni.h +++ b/src/io/jni/paddle_mobile_jni.h @@ -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 */ diff --git a/src/operators/kernel/arm/quantize_kernel.cpp b/src/operators/kernel/arm/quantize_kernel.cpp index 97ffa05c86f15fe6cd7ca18ffef867ad92a61bde..c8af30a65590ef6dd3592da8709b94cba1ee60c6 100644 --- a/src/operators/kernel/arm/quantize_kernel.cpp +++ b/src/operators/kernel/arm/quantize_kernel.cpp @@ -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; } diff --git a/src/operators/kernel/central-arm-func/gru_unit_arm_func.h b/src/operators/kernel/central-arm-func/gru_unit_arm_func.h index 3897d6a308484f942f4a0cbb03957a37f3b7ab4c..603592505d2a2bcb9d6557e2a2369d5e8625a764 100644 --- a/src/operators/kernel/central-arm-func/gru_unit_arm_func.h +++ b/src/operators/kernel/central-arm-func/gru_unit_arm_func.h @@ -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 { diff --git a/src/operators/math/quantize.h b/src/operators/math/quantize.h index 9f9e91330cd9645eb1fbc2fd01192eda4ef0fc7a..9f6b2437f53868341586efdf04b2c8a2a66dac4a 100644 --- a/src/operators/math/quantize.h +++ b/src/operators/math/quantize.h @@ -40,8 +40,8 @@ template <> inline int8_t Round(const float &x) { float v = std::round(x); int32_t q = static_cast(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); } } diff --git a/tools/ci_build.sh b/tools/ci_build.sh index 3697f01063af1844bc7721f77cb31f370069d419..73ff293d4f14a699679284c6bc4e68a6d0d057c7 100755 --- a/tools/ci_build.sh +++ b/tools/ci_build.sh @@ -146,6 +146,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 +164,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