Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / infra / scripts / test_ubuntu_runtime.sh
1 #!/bin/bash
2
3 set -eo pipefail
4 source "$(dirname "${BASH_SOURCE[0]}")/common.sh"
5
6 BACKEND="cpu"
7 TEST_ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
8 TEST_OS="linux"
9 TEST_PLATFORM="$TEST_ARCH-$TEST_OS"
10 TFLITE_LOADER="0"
11 LINEAR_ONLY="0"
12 RUN_INTERP="0"
13
14 function Usage()
15 {
16   echo "Usage: $0 $(basename ${BASH_SOURCE[0]}) [OPTIONS]"
17   echo ""
18   echo "Options:"
19   echo "      --backend <BACKEND>     Runtime backend to test (default: ${BACKEND})"
20   echo "      --tflite-loader         Enable TFLite Loader test"
21   echo "      --linear-only           Use Linear executor only"
22 }
23
24 while [[ $# -gt 0 ]]
25 do
26   arg="$1"
27   case $arg in
28     -h|--help|help)
29       Usage
30       exit 0
31       ;;
32     --backend)
33       BACKEND=$(echo $2 | tr '[:upper:]' '[:lower:]')
34       shift 2
35       ;;
36     --backend=*)
37       BACKEND=$(echo ${1#*=} | tr '[:upper:]' '[:lower:]')
38       shift
39       ;;
40     --tflite-loader)
41       TFLITE_LOADER="1"
42       shift
43       ;;
44     --linear-only)
45       LINEAR_ONLY="1"
46       shift
47       ;;
48     --interp)
49       RUN_INTERP="1"
50       shift;
51       ;;
52     *)
53       # Ignore
54       shift
55       ;;
56   esac
57 done
58
59 CheckTestPrepared
60
61 if [ $RUN_INTERP = "1" ]; then
62   TEST_PLATFORM="noarch"
63   TEST_ARCH="noarch"
64   BACKEND="interp"
65   echo "[[ Interpreter test ]]"
66 else
67   echo "[[ ${TEST_PLATFORM}: ${BACKEND} backend test ]]"
68 fi
69
70 UNITTEST_SKIPLIST="Product/out/unittest/nnapi_gtest.skip.${TEST_PLATFORM}.${BACKEND}"
71 FRAMEWORK_TESTLIST="Product/out/test/list/frameworktest_list.${TEST_ARCH}.${BACKEND}.txt"
72 REPORT_BASE="report/${BACKEND}"
73 EXECUTORS=("Linear" "Dataflow" "Parallel")
74
75 if [ $LINEAR_ONLY = "1" ]; then
76   EXECUTORS=("Linear")
77 fi
78 if [ $RUN_INTERP = "1" ]; then
79   EXECUTORS=("Interpreter")
80 fi
81
82 for EXECUTOR in "${EXECUTORS[@]}";
83 do
84   echo "[EXECUTOR]: ${EXECUTOR}"
85   REPORT_PATH="${REPORT_BASE}/${EXECUTOR}"
86
87   if [ $EXECUTOR = "Interpreter" ]; then
88     export DISABLE_COMPILE=1
89     BACKEND=""
90   else
91     export EXECUTOR="${EXECUTOR}"
92   fi
93
94   NNAPIGTest "${BACKEND}" "${UNITTEST_SKIPLIST}" "${REPORT_PATH}"
95   TFLiteModelVerification "${BACKEND}" "${FRAMEWORK_TESTLIST}" "${REPORT_PATH}"
96
97   if [ $EXECUTOR = "Interpreter" ]; then
98     unset DISABLE_COMPILE
99   else
100     unset EXECUTOR
101   fi
102 done
103
104 # Current support acl_cl backend testlist only
105 # TODO Support more backends
106 TFLITE_LOADER_TESTLIST="Product/out/test/list/tflite_loader_list.${TEST_ARCH}.txt"
107 if [[ $TFLITE_LOADER = "1" ]]; then
108   TFLiteLoaderTest "${BACKEND}" "${TFLITE_LOADER_TESTLIST}" "${REPORT_BASE}/loader/${EXECUTOR}"
109 fi