From b28da5622fd54a0f8b4ddd51c4a3a6266e266e5d Mon Sep 17 00:00:00 2001 From: Donghyeon Jeong Date: Wed, 26 Feb 2025 13:26:06 +0900 Subject: [PATCH] Enhance NNTrainer Android Build This PR aims to enhance the NNTrainer Android build process by addressing compilation warnings and optimizing the android test script for improved performance. **Changes proposed in this PR:** - Warning Fixes: Resolved the compilation warnings that were hindering the build process. - The android test script has been updated to run in parallel, significantly speeding up the testing process. **Self-evaluation:** 1. Build test: [X]Passed [ ]Failed [ ]Skipped 2. Run test: [X]Passed [ ]Failed [ ]Skipped Signed-off-by: Donghyeon Jeong --- nntrainer/layers/gru.cpp | 6 +++--- nntrainer/tensor/char_tensor.h | 2 +- nntrainer/tensor/int4_tensor.h | 2 +- nntrainer/tensor/short_tensor.h | 2 +- nntrainer/tensor/uint_tensor.h | 2 +- tools/android_test.sh | 9 +++++---- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/nntrainer/layers/gru.cpp b/nntrainer/layers/gru.cpp index f9ec829f72..e92683f07c 100644 --- a/nntrainer/layers/gru.cpp +++ b/nntrainer/layers/gru.cpp @@ -425,7 +425,7 @@ void GRULayer::calcGradient(RunLayerContext &context) { context.getTensor(wt_idx[GRUParams::dropout_mask])); } - Tensor dh_nx = Tensor({unit}); + Tensor dh_nx = Tensor(unit); for (unsigned int b = 0; b < batch_size; ++b) { Tensor deriv_t = hidden_state_derivative.getBatchSlice(b, 1); @@ -450,7 +450,7 @@ void GRULayer::calcGradient(RunLayerContext &context) { zrg_.getSharedDataTensor({unit * NUM_GATE}, unit * t * NUM_GATE); if (t == 0) { - prev_hs = Tensor({unit}); + prev_hs = Tensor(unit); prev_hs.setZero(); } else { prev_hs = hs_t.getSharedDataTensor({unit}, (t - 1) * unit); @@ -486,7 +486,7 @@ void GRULayer::calcGradient(RunLayerContext &context) { wzr_hh.copy_with_stride( weight_hh.getSharedDataTensor({1, 1, unit, unit * 2}, 0, false)); - Tensor temp = Tensor({unit}); + Tensor temp = Tensor(unit); if (reset_after) { prev_hs.dot(wg_hh, temp); diff --git a/nntrainer/tensor/char_tensor.h b/nntrainer/tensor/char_tensor.h index 7ae6955f61..4ce62f5664 100644 --- a/nntrainer/tensor/char_tensor.h +++ b/nntrainer/tensor/char_tensor.h @@ -279,7 +279,7 @@ class CharTensor : public TensorBase { /** * @copydoc Tensor::scale_size() */ - QScheme q_scheme() const; + QScheme q_scheme() const override; private: /** diff --git a/nntrainer/tensor/int4_tensor.h b/nntrainer/tensor/int4_tensor.h index 696b761e4b..7856424456 100644 --- a/nntrainer/tensor/int4_tensor.h +++ b/nntrainer/tensor/int4_tensor.h @@ -258,7 +258,7 @@ class Int4QTensor : public TensorBase { /** * @copydoc Tensor::q_scheme() */ - QScheme q_scheme() const; + QScheme q_scheme() const override; private: /** diff --git a/nntrainer/tensor/short_tensor.h b/nntrainer/tensor/short_tensor.h index d1fe384705..3fd67d2361 100644 --- a/nntrainer/tensor/short_tensor.h +++ b/nntrainer/tensor/short_tensor.h @@ -247,7 +247,7 @@ class ShortTensor : public TensorBase { /** * @copydoc Tensor::scale_size() */ - QScheme q_scheme() const; + QScheme q_scheme() const override; private: /** diff --git a/nntrainer/tensor/uint_tensor.h b/nntrainer/tensor/uint_tensor.h index ffa789bc85..eb9ba152cb 100644 --- a/nntrainer/tensor/uint_tensor.h +++ b/nntrainer/tensor/uint_tensor.h @@ -268,7 +268,7 @@ template class UIntTensor : public TensorBase { /** * @copydoc Tensor::q_scheme() */ - QScheme q_scheme() const; + QScheme q_scheme() const override; private: /** diff --git a/tools/android_test.sh b/tools/android_test.sh index d49fc5e63d..6f83d4aac3 100755 --- a/tools/android_test.sh +++ b/tools/android_test.sh @@ -6,21 +6,22 @@ ./tools/package_android.sh # You can modify test/jni/Android.mk to choose module that you wish to build -cd test/jni +pushd test/jni if [ ! -d $ANDROID_NDK ]; then echo "Error: ANDROID_NDK not found." exit 1 fi -ndk-build +ndk-build -j$(nproc) if [ $? != 0 ]; then echo "ndk-build failed" exit 1 fi -cd ../libs/arm64-v8a +popd +pushd test/libs/arm64-v8a adb root @@ -44,7 +45,7 @@ fi # $ meson build [flags...] # meson build will unzip golden data for the unit tests -cd ../../../ +popd if [ ! -d build ]; then meson build -Dopenblas-num-threads=1 -Denable-tflite-interpreter=false -Denable-tflite-backbone=false -Denable-fp16=true -Domp-num-threads=1 -Denable-opencl=true -Dhgemm-experimental-kernel=false else