提交 535473ce 编写于 作者: H Huihuang Zheng

Remove redundant JNI dependencies and replace for loop copy with memcpy

上级 c440043b
...@@ -37,8 +37,7 @@ add_custom_target( ...@@ -37,8 +37,7 @@ add_custom_target(
include_directories(${JNI_INCLUDE_DIRS} ${_classDir} ${_stubDir}) include_directories(${JNI_INCLUDE_DIRS} ${_classDir} ${_stubDir})
lite_cc_library(paddle_lite_jni MODULE SRCS paddle_lite_jni.cc lite_cc_library(paddle_lite_jni MODULE SRCS paddle_lite_jni.cc
DEPS light_api_lite cxx_api_lite DEPS light_api_lite cxx_api_lite
paddle_api_full paddle_api_lite paddle_api_light op_registry_lite paddle_api_full paddle_api_lite paddle_api_light
${ops_lite} ${lite_kernel_deps}
ARM_DEPS ${arm_kernels}) ARM_DEPS ${arm_kernels})
if (APPLE) if (APPLE)
# MacOS only accepts JNI lib ends with .jnilib or .dylib # MacOS only accepts JNI lib ends with .jnilib or .dylib
...@@ -48,5 +47,4 @@ elseif (WIN32) ...@@ -48,5 +47,4 @@ elseif (WIN32)
set_target_properties(paddle_lite_jni PROPERTIES SUFFIX ".dll") set_target_properties(paddle_lite_jni PROPERTIES SUFFIX ".dll")
endif (APPLE) endif (APPLE)
target_link_libraries(paddle_lite_jni light_api_lite cxx_api_lite target_link_libraries(paddle_lite_jni light_api_lite cxx_api_lite
paddle_api_full paddle_api_lite paddle_api_light op_registry_lite paddle_api_full paddle_api_lite paddle_api_light ${arm_kernels})
${ops_lite} ${arm_kernels} ${lite_kernel_deps})
...@@ -248,9 +248,7 @@ Java_com_baidu_paddle_lite_PaddlePredictor_setInput__I_3I_3F( ...@@ -248,9 +248,7 @@ Java_com_baidu_paddle_lite_PaddlePredictor_setInput__I_3I_3F(
predictor->GetInput(static_cast<int>(offset)); predictor->GetInput(static_cast<int>(offset));
tensor->Resize(ddim); tensor->Resize(ddim);
float *input = tensor->mutable_data<float>(); float *input = tensor->mutable_data<float>();
for (int i = 0; i < len; ++i) { memcpy(input, buffer, sizeof(float) * len);
input[i] = buffer[i];
}
return JNI_TRUE; return JNI_TRUE;
} }
...@@ -272,9 +270,7 @@ Java_com_baidu_paddle_lite_PaddlePredictor_setInput__I_3I_3B( ...@@ -272,9 +270,7 @@ Java_com_baidu_paddle_lite_PaddlePredictor_setInput__I_3I_3B(
predictor->GetInput(static_cast<int>(offset)); predictor->GetInput(static_cast<int>(offset));
tensor->Resize(ddim); tensor->Resize(ddim);
int8_t *input = tensor->mutable_data<int8_t>(); int8_t *input = tensor->mutable_data<int8_t>();
for (int i = 0; i < len; ++i) { memcpy(input, buffer, sizeof(int8_t) * len);
input[i] = (int8_t)buffer[i];
}
return JNI_TRUE; return JNI_TRUE;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册