From dbabf5c45db3607bae30f81363107cc1e845e62d Mon Sep 17 00:00:00 2001 From: hong19860320 <9973393+hong19860320@users.noreply.github.com> Date: Fri, 30 Aug 2019 16:00:29 +0800 Subject: [PATCH] [NPU] add NPU supporting for Java API (#1915) * [NPU] add NPU supporting for Java API test=develop * [NPU] refine build script for NPU compiling test=develop * [NPU] fix compiling script for NPU test=develop --- .../jni/src/com/baidu/paddle/lite/Place.java | 6 +-- lite/tools/build_npu.sh | 41 ++++++++++++------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/lite/api/android/jni/src/com/baidu/paddle/lite/Place.java b/lite/api/android/jni/src/com/baidu/paddle/lite/Place.java index 598bb21bd4..98777f3111 100644 --- a/lite/api/android/jni/src/com/baidu/paddle/lite/Place.java +++ b/lite/api/android/jni/src/com/baidu/paddle/lite/Place.java @@ -21,7 +21,7 @@ public class Place { /** Place hardware target type. */ public enum TargetType { - UNKNOWN(0), HOST(1), X86(2), CUDA(3), ARM(4), OPEN_CL(5), ANY(6); + UNKNOWN(0), HOST(1), X86(2), CUDA(3), ARM(4), OPEN_CL(5), FPGA(7), NPU(8), ANY(6); public final int value; @@ -32,7 +32,7 @@ public class Place { /** Place precision type */ public enum PrecisionType { - UNKNOWN(0), FLOAT(1), INT8(2), INT32(3), ANY(4); + UNKNOWN(0), FLOAT(1), INT8(2), FP16(5), INT32(3), ANY(4), BOOL(6); public final int value; @@ -43,7 +43,7 @@ public class Place { /** Place data layout type */ public enum DataLayoutType { - UNKNOWN(0), NCHW(1), ANY(2); + UNKNOWN(0), NCHW(1), NHWC(3), ANY(2); public final int value; diff --git a/lite/tools/build_npu.sh b/lite/tools/build_npu.sh index 24bbd868a4..9d9d6aceae 100755 --- a/lite/tools/build_npu.sh +++ b/lite/tools/build_npu.sh @@ -7,7 +7,7 @@ function print_usage { echo "----------------------------------------" echo -e "--arm_os= android only yet." echo -e "--arm_abi= armv8, armv7 yet." - echo -e "--arm_stl= shared or static" + echo -e "--android_stl= shared or static" echo -e "--arm_lang= " echo -e "--ddk_root= " echo -e "--test_name=" @@ -67,6 +67,7 @@ function cmake_npu { -DWITH_ARM_DOTPROD=ON \ -DLITE_WITH_LIGHT_WEIGHT_FRAMEWORK=ON \ -DWITH_TESTING=ON \ + -DLITE_WITH_JAVA=ON \ -DLITE_WITH_NPU=ON \ -DANDROID_API_LEVEL=24 \ -DARM_TARGET_OS=$1 \ @@ -88,23 +89,23 @@ function build_npu { local test_name=test_npu_pass prepare_thirdparty - if [[ $# -ge 1 ]]; then - os=$1 + if [ "x${ARM_OS}" != "x" ]; then + os=$ARM_OS fi - if [[ $# -ge 2 ]]; then - abi=$2 + if [[ "x${ARM_ABI}" != "x" ]]; then + abi=$ARM_ABI fi - if [[ $# -ge 3 ]]; then - lang=$3 + if [[ "x${ARM_LANG}" != "x" ]]; then + lang=$ARM_LANG fi - if [[ $# -ge 4 ]]; then - stl=$4 + if [[ "x${ANDROID_STL}" != "x" ]]; then + stl=$ANDROID_STL fi - if [[ $# -ge 5 ]]; then - ddk_root=$5 + if [[ "x${DDK_ROOT}" != "x" ]]; then + ddk_root=$DDK_ROOT fi - if [[ $# -ge 6 ]]; then - test_name=$6 + if [[ $# -ge 1 ]]; then + test_name=$1 fi # the c++ symbol is not recognized by the bundled script @@ -149,8 +150,20 @@ function main { ARM_LANG="${i#*=}" shift ;; + --android_stl=*) + ANDROID_STL="${i#*=}" + shift + ;; + --ddk_root=*) + DDK_ROOT="${i#*=}" + shift + ;; build) - build_npu ${os} ${abi} ${lang} ${stl} ${ddk_root} ${test_name} + build_npu $TEST_NAME + shift + ;; + full_publish) + build_npu publish_inference shift ;; *) -- GitLab