Skip to content

Commit

Permalink
Enhance NNTrainer Android Build
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
djeong20 committed Feb 26, 2025
1 parent 150c744 commit e3585ea
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions nntrainer/layers/gru.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion nntrainer/tensor/char_tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class CharTensor : public TensorBase {
/**
* @copydoc Tensor::scale_size()
*/
QScheme q_scheme() const;
QScheme q_scheme() const override;

private:
/**
Expand Down
2 changes: 1 addition & 1 deletion nntrainer/tensor/int4_tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ class Int4QTensor : public TensorBase {
/**
* @copydoc Tensor::q_scheme()
*/
QScheme q_scheme() const;
QScheme q_scheme() const override;

private:
/**
Expand Down
2 changes: 1 addition & 1 deletion nntrainer/tensor/short_tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class ShortTensor : public TensorBase {
/**
* @copydoc Tensor::scale_size()
*/
QScheme q_scheme() const;
QScheme q_scheme() const override;

private:
/**
Expand Down
2 changes: 1 addition & 1 deletion nntrainer/tensor/uint_tensor.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ template <typename T> class UIntTensor : public TensorBase {
/**
* @copydoc Tensor::q_scheme()
*/
QScheme q_scheme() const;
QScheme q_scheme() const override;

private:
/**
Expand Down
9 changes: 5 additions & 4 deletions tools/android_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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 -Denable-neon=true -Domp-num-threads=1 -Denable-opencl=true -Dhgemm-experimental-kernel=false
else
Expand Down

0 comments on commit e3585ea

Please sign in to comment.