blob: 48b23721ba22e82d5e131b123c80080be397ac11 [file] [log] [blame]
James Conroy919ec712022-07-13 12:57:53 +01001#!/bin/bash
2#
3# Copyright © 2022 Arm Ltd and Contributors. All rights reserved.
4# SPDX-License-Identifier: MIT
5#
6
7# Common validation of command line arguments provided to setup-armnn.sh and build-armnn.sh
8
9# shellcheck disable=SC2034,SC2154
10# SC2034: false positives for variables appear unused - variables are used in setup-armnn.sh and build-armnn.sh
11# SC2154: false positives for variables referenced but not assigned - variables are assigned in setup-armnn.sh and build-armnn.sh
12
13set -o nounset # Catch references to undefined variables.
14set -o pipefail # Catch non zero exit codes within pipelines.
15set -o errexit # Catch and propagate non zero exit codes.
16
17# Host and target architecture validation
18if [ "$target_arch" == "" ]; then
19 echo "$name: --target-arch is not set. Example usage: --target-arch=aarch64"
20 exit 1
21fi
22
James Conroye6f30ad2022-09-08 12:04:26 +010023if [ "$target_arch" != "aarch64" ] && [ "$target_arch" != "x86_64" ]; then
24 echo "$name: --target-arch is not valid. Valid options are: aarch64, x86_64"
James Conroy919ec712022-07-13 12:57:53 +010025 exit 1
26fi
27
28if [ "$HOST_ARCH" == "aarch64" ]; then
29 if [ "$target_arch" != "aarch64" ]; then
30 echo "$name: aarch64 is the only supported --target_arch when host is aarch64"
31 exit 1
32 fi
33fi
34
James Conroy919ec712022-07-13 12:57:53 +010035# Validation of chosen Arm NN dependencies
Nikhil Raj6aed53b2023-05-04 09:34:46 +010036if [ "$flag_tflite_classic_delegate" -eq 0 ] && [ "$flag_tflite_opaque_delegate" -eq 0 ] && [ "$flag_tflite_parser" -eq 0 ] && [ "$flag_onnx_parser" -eq 0 ]; then
Nikhil Raj542c8482023-04-26 16:22:10 +010037 echo "$name: at least one of flags --tflite-classic-delegate, --tflite-opaque-delegate, --tflite-parser or --onnx-parser must be set (or --all)."
James Conroy919ec712022-07-13 12:57:53 +010038 exit 1
39fi
40
41# If --num-threads is set, overwrite default NUM_THREADS with user-defined value
42if [ ! "$num_threads" -eq 0 ]; then
43 NUM_THREADS="$num_threads"
44fi