From 535473ce4907f8a6fe641cd54abfc6cf922bb180 Mon Sep 17 00:00:00 2001 From: Huihuang Zheng Date: Fri, 28 Jun 2019 09:55:34 +0000 Subject: [PATCH] Remove redundant JNI dependencies and replace for loop copy with memcpy --- paddle/fluid/lite/api/android/jni/CMakeLists.txt | 6 ++---- paddle/fluid/lite/api/android/jni/paddle_lite_jni.cc | 8 ++------ 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/paddle/fluid/lite/api/android/jni/CMakeLists.txt b/paddle/fluid/lite/api/android/jni/CMakeLists.txt index 0ce3b606e80..245fd45859c 100644 --- a/paddle/fluid/lite/api/android/jni/CMakeLists.txt +++ b/paddle/fluid/lite/api/android/jni/CMakeLists.txt @@ -37,8 +37,7 @@ add_custom_target( include_directories(${JNI_INCLUDE_DIRS} ${_classDir} ${_stubDir}) lite_cc_library(paddle_lite_jni MODULE SRCS paddle_lite_jni.cc DEPS light_api_lite cxx_api_lite - paddle_api_full paddle_api_lite paddle_api_light op_registry_lite - ${ops_lite} ${lite_kernel_deps} + paddle_api_full paddle_api_lite paddle_api_light ARM_DEPS ${arm_kernels}) if (APPLE) # MacOS only accepts JNI lib ends with .jnilib or .dylib @@ -48,5 +47,4 @@ elseif (WIN32) set_target_properties(paddle_lite_jni PROPERTIES SUFFIX ".dll") endif (APPLE) target_link_libraries(paddle_lite_jni light_api_lite cxx_api_lite - paddle_api_full paddle_api_lite paddle_api_light op_registry_lite - ${ops_lite} ${arm_kernels} ${lite_kernel_deps}) + paddle_api_full paddle_api_lite paddle_api_light ${arm_kernels}) diff --git a/paddle/fluid/lite/api/android/jni/paddle_lite_jni.cc b/paddle/fluid/lite/api/android/jni/paddle_lite_jni.cc index 4ef0c2ee55d..dc5bd8e1a36 100644 --- a/paddle/fluid/lite/api/android/jni/paddle_lite_jni.cc +++ b/paddle/fluid/lite/api/android/jni/paddle_lite_jni.cc @@ -248,9 +248,7 @@ Java_com_baidu_paddle_lite_PaddlePredictor_setInput__I_3I_3F( predictor->GetInput(static_cast(offset)); tensor->Resize(ddim); float *input = tensor->mutable_data(); - for (int i = 0; i < len; ++i) { - input[i] = buffer[i]; - } + memcpy(input, buffer, sizeof(float) * len); return JNI_TRUE; } @@ -272,9 +270,7 @@ Java_com_baidu_paddle_lite_PaddlePredictor_setInput__I_3I_3B( predictor->GetInput(static_cast(offset)); tensor->Resize(ddim); int8_t *input = tensor->mutable_data(); - for (int i = 0; i < len; ++i) { - input[i] = (int8_t)buffer[i]; - } + memcpy(input, buffer, sizeof(int8_t) * len); return JNI_TRUE; } -- GitLab