From 3960508406815f2d61e49f313b063bb5b3fb2bad Mon Sep 17 00:00:00 2001 From: Mark Horvath Date: Wed, 22 May 2024 16:35:16 +0200 Subject: [PATCH 1/2] Add patch to extend OpenCV performance test suites Benchmark script updated to apply the patch automatically. Minor fixes applied to the benchmark readme. Transpose related tests are removed from the benchmark lists. --- .../opencv/extra_benchmarks/opencv-4.9.patch | 209 ++++++++++++++++++ scripts/benchmark/README.md | 6 +- scripts/benchmark/build.sh | 8 +- scripts/benchmark/run_benchmarks_4K.sh | 4 - scripts/benchmark/run_benchmarks_FHD.sh | 4 - 5 files changed, 221 insertions(+), 10 deletions(-) create mode 100644 adapters/opencv/extra_benchmarks/opencv-4.9.patch diff --git a/adapters/opencv/extra_benchmarks/opencv-4.9.patch b/adapters/opencv/extra_benchmarks/opencv-4.9.patch new file mode 100644 index 000000000..e73dd94f3 --- /dev/null +++ b/adapters/opencv/extra_benchmarks/opencv-4.9.patch @@ -0,0 +1,209 @@ +// SPDX-FileCopyrightText: 2024 Arm Limited and/or its affiliates +// +// SPDX-License-Identifier: Apache-2.0 + +diff --git a/modules/core/perf/perf_convertTo.cpp b/modules/core/perf/perf_convertTo.cpp +index 344d81cb8a..ef5a3aa7d2 100644 +--- a/modules/core/perf/perf_convertTo.cpp ++++ b/modules/core/perf/perf_convertTo.cpp +@@ -4,17 +4,18 @@ namespace opencv_test + { + using namespace perf; + +-typedef tuple Size_DepthSrc_DepthDst_Channels_alpha_t; +-typedef perf::TestBaseWithParam Size_DepthSrc_DepthDst_Channels_alpha; ++typedef tuple Size_DepthSrc_DepthDst_Channels_alpha_beta_t; ++typedef perf::TestBaseWithParam Size_DepthSrc_DepthDst_Channels_alpha_beta; + +-PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo, ++PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha_beta, convertTo, + testing::Combine + ( +- testing::Values(szVGA, sz1080p), ++ testing::Values(sz1080p, sz2160p), + testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F), + testing::Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F), + testing::Values(1, 4), +- testing::Values(1.0, 1./255) ++ testing::Values(1.0, 1./255, 1.234), ++ testing::Values(0, 4.567) + ) + ) + { +@@ -23,6 +24,7 @@ PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo, + int depthDst = get<2>(GetParam()); + int channels = get<3>(GetParam()); + double alpha = get<4>(GetParam()); ++ double beta = get<5>(GetParam()); + + int maxValue = 255; + +@@ -31,7 +33,7 @@ PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo, + Mat dst(sz, CV_MAKETYPE(depthDst, channels)); + + int runs = (sz.width <= 640) ? 8 : 1; +- TEST_CYCLE_MULTIRUN(runs) src.convertTo(dst, depthDst, alpha); ++ TEST_CYCLE_MULTIRUN(runs) src.convertTo(dst, depthDst, alpha, beta); + + double eps = depthSrc <= CV_32S && (depthDst <= CV_32S || depthDst == CV_64F) ? 1e-12 : (FLT_EPSILON * maxValue); + eps = eps * std::max(1.0, fabs(alpha)); +diff --git a/modules/imgproc/perf/perf_blur.cpp b/modules/imgproc/perf/perf_blur.cpp +index d1f5a6b1ca..c4a3a6cdc5 100644 +--- a/modules/imgproc/perf/perf_blur.cpp ++++ b/modules/imgproc/perf/perf_blur.cpp +@@ -47,7 +47,7 @@ typedef perf::TestBaseWithParam Size_ksize_BorderType; + + PERF_TEST_P(Size_MatType_BorderType3x3, gaussianBlur3x3, + testing::Combine( +- testing::Values(szODD, szQVGA, szVGA, sz720p), ++ testing::Values(szODD, szQVGA, szVGA, sz720p, sz1080p, sz2160p), + testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1), + BorderType3x3::all() + ) +@@ -188,7 +188,7 @@ PERF_TEST_P(Size_MatType_BorderType3x3, box3x3_inplace, + + PERF_TEST_P(Size_MatType_BorderType, gaussianBlur5x5, + testing::Combine( +- testing::Values(szODD, szQVGA, szVGA, sz720p), ++ testing::Values(szODD, szQVGA, szVGA, sz720p, sz1080p, sz2160p), + testing::Values(CV_8UC1, CV_8UC4, CV_16UC1, CV_16SC1, CV_32FC1), + BorderType::all() + ) +diff --git a/modules/imgproc/perf/perf_cvt_color.cpp b/modules/imgproc/perf/perf_cvt_color.cpp +index 5915b507ce..4a8c02df40 100644 +--- a/modules/imgproc/perf/perf_cvt_color.cpp ++++ b/modules/imgproc/perf/perf_cvt_color.cpp +@@ -319,7 +319,7 @@ typedef perf::TestBaseWithParam Size_CvtMode; + + PERF_TEST_P(Size_CvtMode, cvtColor8u, + testing::Combine( +- testing::Values(::perf::szODD, ::perf::szVGA, ::perf::sz1080p), ++ testing::Values(::perf::szODD, ::perf::szVGA, ::perf::sz1080p, ::perf::sz2160p), + CvtMode::all() + ) + ) +@@ -435,7 +435,7 @@ typedef perf::TestBaseWithParam Size_CvtMode2; + + PERF_TEST_P(Size_CvtMode2, cvtColorYUV420, + testing::Combine( +- testing::Values(szVGA, sz1080p, Size(130, 60)), ++ testing::Values(szVGA, sz1080p, sz2160p, Size(130, 60)), + CvtMode2::all() + ) + ) +diff --git a/modules/imgproc/perf/perf_morph.cpp b/modules/imgproc/perf/perf_morph.cpp +index dc9e975a21..1b73c5eaee 100644 +--- a/modules/imgproc/perf/perf_morph.cpp ++++ b/modules/imgproc/perf/perf_morph.cpp +@@ -39,4 +39,64 @@ PERF_TEST_P(Size_MatType, dilate, TYPICAL_MATS_MORPH) + SANITY_CHECK(dst); + } + ++typedef tuple MorphParams_t; ++typedef perf::TestBaseWithParam Erode; ++typedef perf::TestBaseWithParam Dilate; ++ ++PERF_TEST_P(Erode, big, ++ testing::Combine( ++ testing::Values(::perf::sz1080p, ::perf::sz2160p), ++ testing::Values(CV_8UC1), ++ testing::Values(3, 5, 17) ++ )) ++{ ++ Size sz = get<0>(GetParam()); ++ int type = get<1>(GetParam()); ++ int kernelSize = get<2>(GetParam()); ++ ++ Mat src(sz, type); ++ Mat dst(sz, type); ++ ++ declare.in(src, WARMUP_RNG).out(dst); ++ ++ const cv::MorphShapes morph_shape = cv::MorphShapes::MORPH_RECT; ++ const cv::Size kernel{kernelSize, kernelSize}; ++ const cv::Point anchor{-1, -1}; ++ ++ cv::Mat element = cv::getStructuringElement(morph_shape, kernel, anchor); ++ ++ TEST_CYCLE() erode(src, dst, element, cv::Point(-1, -1), 1, ++ cv::BorderTypes::BORDER_CONSTANT, cv::Scalar(0xAA)); ++ ++ SANITY_CHECK(dst); ++} ++ ++PERF_TEST_P(Dilate, big, ++ testing::Combine( ++ testing::Values(::perf::sz1080p, ::perf::sz2160p), ++ testing::Values(CV_8UC1), ++ testing::Values(3, 5, 17) ++ )) ++{ ++ Size sz = get<0>(GetParam()); ++ int type = get<1>(GetParam()); ++ int kernelSize = get<2>(GetParam()); ++ ++ Mat src(sz, type); ++ Mat dst(sz, type); ++ ++ declare.in(src, WARMUP_RNG).out(dst); ++ ++ const cv::MorphShapes morph_shape = cv::MorphShapes::MORPH_RECT; ++ const cv::Size kernel{kernelSize, kernelSize}; ++ const cv::Point anchor{-1, -1}; ++ ++ cv::Mat element = cv::getStructuringElement(morph_shape, kernel, anchor); ++ ++ TEST_CYCLE() dilate(src, dst, element, cv::Point(-1, -1), 1, ++ cv::BorderTypes::BORDER_CONSTANT, cv::Scalar(0xAA)); ++ ++ SANITY_CHECK(dst); ++} ++ + } // namespace +diff --git a/modules/imgproc/perf/perf_resize.cpp b/modules/imgproc/perf/perf_resize.cpp +index 0f470a5f81..89e4f746e1 100644 +--- a/modules/imgproc/perf/perf_resize.cpp ++++ b/modules/imgproc/perf/perf_resize.cpp +@@ -67,7 +67,15 @@ PERF_TEST_P(MatInfo_SizePair, resizeUpLinearNonExact, + testing::Combine + ( + testing::Values( MATTYPE_NE_VALUES ), +- testing::Values( Size_Size_t(szVGA, szqHD), Size_Size_t(szVGA, sz720p) ) ++ testing::Values ++ ( ++ // 2*2 ++ Size_Size_t(szqHD, sz1080p), ++ Size_Size_t(sz1080p, sz2160p), ++ // 4*4 ++ Size_Size_t(cv::Size(480, 270), sz1080p), ++ Size_Size_t(szqHD, sz2160p) ++ ) + ) + ) + { +diff --git a/modules/imgproc/perf/perf_sepfilters.cpp b/modules/imgproc/perf/perf_sepfilters.cpp +index 480aab9f20..8eb1667f2f 100644 +--- a/modules/imgproc/perf/perf_sepfilters.cpp ++++ b/modules/imgproc/perf/perf_sepfilters.cpp +@@ -5,7 +5,7 @@ + + namespace opencv_test { + +-#define FILTER_SRC_SIZES szODD, szQVGA, szVGA ++#define FILTER_SRC_SIZES szODD, szQVGA, szVGA, sz1080p, sz2160p + + CV_ENUM(BorderType3x3, BORDER_REPLICATE, BORDER_CONSTANT) + CV_ENUM(BorderType3x3ROI, BORDER_DEFAULT, BORDER_REPLICATE|BORDER_ISOLATED, BORDER_CONSTANT|BORDER_ISOLATED) +diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp +index 7aa3809f27..9ff587f325 100644 +--- a/modules/ts/include/opencv2/ts/ts_perf.hpp ++++ b/modules/ts/include/opencv2/ts/ts_perf.hpp +@@ -78,7 +78,7 @@ const static cv::Size szSmall128 = cv::Size(128, 128); + #define SZ_TYPICAL ::testing::Values(::perf::szVGA, ::perf::szqHD, ::perf::sz720p, ::perf::szODD) + + +-#define TYPICAL_MAT_SIZES ::perf::szVGA, ::perf::sz720p, ::perf::sz1080p, ::perf::szODD ++#define TYPICAL_MAT_SIZES ::perf::szVGA, ::perf::sz720p, ::perf::sz1080p, ::perf::szODD, ::perf::sz2160p + #define TYPICAL_MAT_TYPES CV_8UC1, CV_8UC4, CV_32FC1 + #define TYPICAL_MATS testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( TYPICAL_MAT_TYPES ) ) + #define TYPICAL_MATS_C1 testing::Combine( testing::Values( TYPICAL_MAT_SIZES ), testing::Values( CV_8UC1, CV_32FC1 ) ) diff --git a/scripts/benchmark/README.md b/scripts/benchmark/README.md index e9ed2ec72..3db95758c 100644 --- a/scripts/benchmark/README.md +++ b/scripts/benchmark/README.md @@ -10,13 +10,17 @@ Use at your own risk. First, you need a Linux x86 machine to build this. Next, to build for Android, you'll need [Android NDK](https://developer.android.com/ndk/). +Also, the OpenCV 4.9.0 source should be downloaded. Let's assume you are building on a machine that has the phone attached to via USB. Let's assume your CWD is this directory. Stay in this directory. ``` -KLEIDICV_PATH=../.. ./build.sh +KLEIDICV_PATH=../.. \ +OPENCV_PATH= \ +NDK_TOOLCHAIN_FILE=/build/cmake/android.toolchain.cmake \ +./build.sh ``` Then push the test binaries to the phone (replace 9A9A9A9A with your actual device ID, or skip it if you have only one phone attached): ``` diff --git a/scripts/benchmark/build.sh b/scripts/benchmark/build.sh index dd5579f22..27b5b3ddd 100755 --- a/scripts/benchmark/build.sh +++ b/scripts/benchmark/build.sh @@ -22,9 +22,15 @@ if [ ! -f "${NDK_TOOLCHAIN_FILE:-}" ]; then fi OPENCV_PATCH=$(realpath "${KLEIDICV_PATH}")/adapters/opencv/opencv-4.9.patch +OPENCV_BENCHMARK_PATCH=$(realpath "${KLEIDICV_PATH}")/adapters/opencv/extra_benchmarks/opencv-4.9.patch pushd ${OPENCV_PATH} -if [ "patch --forward -p1<${OPENCV_PATCH}" -gt 1 ]; then +if [ "patch --forward -p1<${OPENCV_PATCH}" -gt 0 ]; then + echo patch failed! + exit 2 +fi + +if [ "patch --forward -p1<${OPENCV_BENCHMARK_PATCH}" -gt 0 ]; then echo patch failed! exit 2 fi diff --git a/scripts/benchmark/run_benchmarks_4K.sh b/scripts/benchmark/run_benchmarks_4K.sh index e44b3ebf0..d51b6a72f 100755 --- a/scripts/benchmark/run_benchmarks_4K.sh +++ b/scripts/benchmark/run_benchmarks_4K.sh @@ -52,9 +52,5 @@ RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL Resize4x4_8b op RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL Resize4x4_float opencv_perf_imgproc '*resizeUpLinearNonExact*' '(32FC1, (960x540, 3840x2160))')") RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL Scale opencv_perf_core '*convertTo*' '(3840x2160, 8UC1, 8UC1, 1, 1.234, 4.567)')") -RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL TransposeInplace_8b opencv_perf_core '*Transpose_InPlace*' '(3840x2160, 8UC1)')") -RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL TransposeInplace_16b opencv_perf_core '*Transpose_InPlace*' '(3840x2160, 16UC1)')") -RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL TransposeCopy_8b opencv_perf_core '*Transpose_Copy*' '(3840x2160, 8UC1)')") -RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL TransposeCopy_16b opencv_perf_core '*Transpose_Copy*' '(3840x2160, 16UC1)')") echo "$RES" diff --git a/scripts/benchmark/run_benchmarks_FHD.sh b/scripts/benchmark/run_benchmarks_FHD.sh index 9a9aa5f46..2f21a29bd 100755 --- a/scripts/benchmark/run_benchmarks_FHD.sh +++ b/scripts/benchmark/run_benchmarks_FHD.sh @@ -52,9 +52,5 @@ RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL Resize4x4_8b op RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL Resize4x4_float opencv_perf_imgproc '*resizeUpLinearNonExact*' '(32FC1, (480x270, 1920x1080))')") RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL Scale opencv_perf_core '*convertTo*' '(1920x1080, 8UC1, 8UC1, 1, 1.234, 4.567)')") -RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL TransposeInplace_8b opencv_perf_core '*Transpose_InPlace*' '(1920x1080, 8UC1)')") -RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL TransposeInplace_16b opencv_perf_core '*Transpose_InPlace*' '(1920x1080, 16UC1)')") -RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL TransposeCopy_8b opencv_perf_core '*Transpose_Copy*' '(1920x1080, 8UC1)')") -RES=$(printf "${RES}\n$(${DEV_DIR}/perf_test_op.sh $CPU $THERMAL TransposeCopy_16b opencv_perf_core '*Transpose_Copy*' '(1920x1080, 16UC1)')") echo "$RES" -- GitLab From 444e9a77ddbb9b5f7f38eb7d954d2cc6268617c9 Mon Sep 17 00:00:00 2001 From: Akos Denke Date: Tue, 21 May 2024 13:36:56 +0200 Subject: [PATCH 2/2] Improve example benchmarking scripts * Patching of OpenCV is removed from the build script, as the patch command does not always notice that a patch is already applied. * Scripts can be run from any path. * Description added for CUSTOM_CMAKE_OPTIONS in case of the build script. * No need to specify KLEIDICV_PATH in case of the build script. * Special env variables are removed from push.sh in favour of the official ADB ones. --- scripts/benchmark/README.md | 15 +++++++++--- scripts/benchmark/build.sh | 44 +++++++++++----------------------- scripts/benchmark/push.sh | 47 +++++++++++++------------------------ 3 files changed, 42 insertions(+), 64 deletions(-) diff --git a/scripts/benchmark/README.md b/scripts/benchmark/README.md index 3db95758c..13751f349 100644 --- a/scripts/benchmark/README.md +++ b/scripts/benchmark/README.md @@ -10,18 +10,27 @@ Use at your own risk. First, you need a Linux x86 machine to build this. Next, to build for Android, you'll need [Android NDK](https://developer.android.com/ndk/). -Also, the OpenCV 4.9.0 source should be downloaded. + +Also, the OpenCV 4.9.0 source needs to be downloaded and patched. Assuming CWD is the root of OpenCV's +source directory please run : +``` +patch -p1 \ NDK_TOOLCHAIN_FILE=/build/cmake/android.toolchain.cmake \ ./build.sh ``` + +If the `CUSTOM_CMAKE_OPTIONS` environment variable is set a third flavour is also build, next to vanilla +OpenCV and OpenCV+KleidiCV with default options. The variable specifies the extra CMake variables for this +custom build. + Then push the test binaries to the phone (replace 9A9A9A9A with your actual device ID, or skip it if you have only one phone attached): ``` ADB=adb ANDROID_SERIAL=9A9A9A9A ./push.sh diff --git a/scripts/benchmark/build.sh b/scripts/benchmark/build.sh index 27b5b3ddd..7a102862e 100755 --- a/scripts/benchmark/build.sh +++ b/scripts/benchmark/build.sh @@ -6,12 +6,7 @@ set -exu -if [[ -z "${KLEIDICV_PATH}" ]]; then - echo "Please specify the local path to a checked out (cloned) KleidiCV repo in the KLEIDICV_PATH env variable" - exit 1 -fi - -if [[ -z "${OPENCV_PATH}" ]]; then +if [[ -z "${OPENCV_PATH:-}" ]]; then echo "Please specify the local path to a checked out (cloned) OpenCV repo in the OPENCV_PATH env variable" exit 1 fi @@ -21,23 +16,12 @@ if [ ! -f "${NDK_TOOLCHAIN_FILE:-}" ]; then exit 1 fi -OPENCV_PATCH=$(realpath "${KLEIDICV_PATH}")/adapters/opencv/opencv-4.9.patch -OPENCV_BENCHMARK_PATCH=$(realpath "${KLEIDICV_PATH}")/adapters/opencv/extra_benchmarks/opencv-4.9.patch - -pushd ${OPENCV_PATH} -if [ "patch --forward -p1<${OPENCV_PATCH}" -gt 0 ]; then - echo patch failed! - exit 2 -fi - -if [ "patch --forward -p1<${OPENCV_BENCHMARK_PATCH}" -gt 0 ]; then - echo patch failed! - exit 2 -fi -popd +SCRIPT_PATH="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")" +KLEIDICV_PATH="${SCRIPT_PATH}"/../.. +BASE_BUILD_PATH="${SCRIPT_PATH}"/build -cmake -S ${OPENCV_PATH} \ - -B build/vanilla \ +cmake -S "${OPENCV_PATH}" \ + -B "${BASE_BUILD_PATH}"/vanilla \ -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_STANDARD=14 \ @@ -50,10 +34,10 @@ cmake -S ${OPENCV_PATH} \ -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON \ -DWITH_KLEIDICV=OFF -ninja -C build/vanilla opencv_perf_imgproc opencv_perf_core +ninja -C "${BASE_BUILD_PATH}"/vanilla opencv_perf_imgproc opencv_perf_core -cmake -S ${OPENCV_PATH} \ - -B build/kleidicv \ +cmake -S "${OPENCV_PATH}" \ + -B "${BASE_BUILD_PATH}"/kleidicv \ -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_STANDARD=14 \ @@ -67,14 +51,14 @@ cmake -S ${OPENCV_PATH} \ -DWITH_KLEIDICV=ON \ -DKLEIDICV_SOURCE_PATH=$(realpath "${KLEIDICV_PATH}") -ninja -C build/kleidicv opencv_perf_imgproc opencv_perf_core +ninja -C "${BASE_BUILD_PATH}"/kleidicv opencv_perf_imgproc opencv_perf_core -if [[ -z "${CUSTOM_CMAKE_OPTIONS}" ]]; then +if [[ -z "${CUSTOM_CMAKE_OPTIONS:-}" ]]; then exit 0; fi -cmake -S ${OPENCV_PATH} \ - -B build/kleidicv_custom \ +cmake -S "${OPENCV_PATH}" \ + -B "${BASE_BUILD_PATH}"/kleidicv_custom \ -G Ninja \ -DCMAKE_BUILD_TYPE=Release \ -DCMAKE_CXX_STANDARD=14 \ @@ -89,4 +73,4 @@ cmake -S ${OPENCV_PATH} \ -DKLEIDICV_SOURCE_PATH=$(realpath "${KLEIDICV_PATH}") \ ${CUSTOM_CMAKE_OPTIONS} -ninja -C build/kleidicv_custom opencv_perf_imgproc opencv_perf_core +ninja -C "${BASE_BUILD_PATH}"/kleidicv_custom opencv_perf_imgproc opencv_perf_core diff --git a/scripts/benchmark/push.sh b/scripts/benchmark/push.sh index 8eb97eba9..d9c8876ce 100755 --- a/scripts/benchmark/push.sh +++ b/scripts/benchmark/push.sh @@ -6,47 +6,32 @@ # Environment variables used: # ADB: adb executable. Must be set. -# ANDROID_SERIAL: Passed to adb it selects a device by its serial number. This is optional. -# DEVICE_HOST: Passed to adb it sets the host where the device is found. This is optional. -# DEVICE_PORT: Passed to adb it sets the port where the device is found. This is optional. +# Note: +# Use standard ADB env vars (like ANDROID_SERIAL, ANDROID_ADB_SERVER_ADDRESS and +# ANDROID_ADB_SERVER_PORT) to customize ADB calls. set -exu -run_adb_command() { - local args=() - if [[ -n "${DEVICE_HOST+x}" ]]; then - args+=( "-H" "${DEVICE_HOST}" ) - fi - if [[ -n "${DEVICE_PORT+x}" ]]; then - args+=( "-P" "${DEVICE_PORT}" ) - fi - if [[ -n "${ANDROID_SERIAL+x}" ]]; then - args+=( "-s" "${ANDROID_SERIAL}" ) - fi - - "${ADB}" "${args[@]}" "$@" -} - -if [[ -z "${ADB}" ]]; then - echo "Required variable 'ADB' is not set. Please set it to point to adb command." - exit 1 +if [[ -z "${ADB:-}" ]]; then + echo "Required variable 'ADB' is not set. Please set it to point to adb command." + exit 1 fi SCRIPT_PATH="$(realpath "$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)")" DEV_DIR=/data/local/tmp -run_adb_command push build/vanilla/bin/opencv_perf_core ${DEV_DIR}/opencv_perf_core_vanilla -run_adb_command push build/vanilla/bin/opencv_perf_imgproc ${DEV_DIR}/opencv_perf_imgproc_vanilla +"${ADB}" push "${SCRIPT_PATH}"/build/vanilla/bin/opencv_perf_core ${DEV_DIR}/opencv_perf_core_vanilla +"${ADB}" push "${SCRIPT_PATH}"/build/vanilla/bin/opencv_perf_imgproc ${DEV_DIR}/opencv_perf_imgproc_vanilla -run_adb_command push build/kleidicv/bin/opencv_perf_core ${DEV_DIR}/opencv_perf_core_kleidicv -run_adb_command push build/kleidicv/bin/opencv_perf_imgproc ${DEV_DIR}/opencv_perf_imgproc_kleidicv +"${ADB}" push "${SCRIPT_PATH}"/build/kleidicv/bin/opencv_perf_core ${DEV_DIR}/opencv_perf_core_kleidicv +"${ADB}" push "${SCRIPT_PATH}"/build/kleidicv/bin/opencv_perf_imgproc ${DEV_DIR}/opencv_perf_imgproc_kleidicv -if [ -f build/kleidicv_custom/bin/opencv_perf_core ] && [ -f build/kleidicv_custom/bin/opencv_perf_imgproc ]; then - run_adb_command push build/kleidicv_custom/bin/opencv_perf_core ${DEV_DIR}/opencv_perf_core_custom - run_adb_command push build/kleidicv_custom/bin/opencv_perf_imgproc ${DEV_DIR}/opencv_perf_imgproc_custom +if [[ -f "${SCRIPT_PATH}"/build/kleidicv_custom/bin/opencv_perf_core && -f "${SCRIPT_PATH}"/build/kleidicv_custom/bin/opencv_perf_imgproc ]]; then + "${ADB}" push "${SCRIPT_PATH}"/build/kleidicv_custom/bin/opencv_perf_core ${DEV_DIR}/opencv_perf_core_custom + "${ADB}" push "${SCRIPT_PATH}"/build/kleidicv_custom/bin/opencv_perf_imgproc ${DEV_DIR}/opencv_perf_imgproc_custom fi -run_adb_command push ${SCRIPT_PATH}/perf_test_op.sh ${DEV_DIR}/ -run_adb_command push ${SCRIPT_PATH}/run_benchmarks_FHD.sh ${DEV_DIR}/ -run_adb_command push ${SCRIPT_PATH}/run_benchmarks_4K.sh ${DEV_DIR}/ +"${ADB}" push "${SCRIPT_PATH}"/perf_test_op.sh ${DEV_DIR}/ +"${ADB}" push "${SCRIPT_PATH}"/run_benchmarks_FHD.sh ${DEV_DIR}/ +"${ADB}" push "${SCRIPT_PATH}"/run_benchmarks_4K.sh ${DEV_DIR}/ -- GitLab