summaryrefslogtreecommitdiff
path: root/infra/scripts/test_ubuntu_runtime.sh
blob: f250df5a018835974355c34e74944b1c4942c77c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/bash

set -eo pipefail
source "$(dirname "${BASH_SOURCE[0]}")/common.sh"

BACKEND="cpu"
TEST_ARCH=$(uname -m | tr '[:upper:]' '[:lower:]')
TEST_OS="linux"
TEST_PLATFORM="$TEST_ARCH-$TEST_OS"
TFLITE_LOADER="0"
LINEAR_ONLY="0"
RUN_INTERP="0"

function Usage()
{
  echo "Usage: $0 $(basename ${BASH_SOURCE[0]}) [OPTIONS]"
  echo ""
  echo "Options:"
  echo "      --backend <BACKEND>     Runtime backend to test (default: ${BACKEND})"
  echo "      --tflite-loader         Enable TFLite Loader test"
  echo "      --linear-only           Use Linear executor only"
}

while [[ $# -gt 0 ]]
do
  arg="$1"
  case $arg in
    -h|--help|help)
      Usage
      exit 0
      ;;
    --backend)
      BACKEND=$(echo $2 | tr '[:upper:]' '[:lower:]')
      shift 2
      ;;
    --backend=*)
      BACKEND=$(echo ${1#*=} | tr '[:upper:]' '[:lower:]')
      shift
      ;;
    --tflite-loader)
      TFLITE_LOADER="1"
      shift
      ;;
    --linear-only)
      LINEAR_ONLY="1"
      shift
      ;;
    --interp)
      RUN_INTERP="1"
      shift;
      ;;
    *)
      # Ignore
      shift
      ;;
  esac
done

CheckTestPrepared

if [ $RUN_INTERP = "1" ]; then
  TEST_PLATFORM="noarch"
  TEST_ARCH="noarch"
  BACKEND="interp"
  echo "[[ Interpreter test ]]"
else
  echo "[[ ${TEST_PLATFORM}: ${BACKEND} backend test ]]"
fi

UNITTEST_SKIPLIST="Product/out/unittest/nnapi_gtest.skip.${TEST_PLATFORM}.${BACKEND}"
FRAMEWORK_TESTLIST="Product/out/test/list/frameworktest_list.${TEST_ARCH}.${BACKEND}.txt"
REPORT_BASE="report/${BACKEND}"
EXECUTORS=("Linear" "Dataflow" "Parallel")

if [ $LINEAR_ONLY = "1" ]; then
  EXECUTORS=("Linear")
fi
if [ $RUN_INTERP = "1" ]; then
  EXECUTORS=("Interpreter")
fi

for EXECUTOR in "${EXECUTORS[@]}";
do
  echo "[EXECUTOR]: ${EXECUTOR}"
  REPORT_PATH="${REPORT_BASE}/${EXECUTOR}"

  if [ $EXECUTOR = "Interpreter" ]; then
    export DISABLE_COMPILE=1
    BACKEND=""
  else
    export EXECUTOR="${EXECUTOR}"
  fi

  NNAPIGTest "${BACKEND}" "${UNITTEST_SKIPLIST}" "${REPORT_PATH}"
  TFLiteModelVerification "${BACKEND}" "${FRAMEWORK_TESTLIST}" "${REPORT_PATH}"

  if [ $EXECUTOR = "Interpreter" ]; then
    unset DISABLE_COMPILE
  else
    unset EXECUTOR
  fi
done

# Current support acl_cl backend testlist only
# TODO Support more backends
TFLITE_LOADER_TESTLIST="Product/out/test/list/tflite_loader_list.${TEST_ARCH}.txt"
if [[ $TFLITE_LOADER = "1" ]]; then
  TFLiteLoaderTest "${BACKEND}" "${TFLITE_LOADER_TESTLIST}" "${REPORT_BASE}/loader/${EXECUTOR}"
fi