James Conroy | 919ec71 | 2022-07-13 12:57:53 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # |
Tracy Narine | 2883a86 | 2024-02-26 15:05:11 +0000 | [diff] [blame] | 3 | # Copyright © 2022-2024 Arm Ltd and Contributors. All rights reserved. |
James Conroy | 919ec71 | 2022-07-13 12:57:53 +0100 | [diff] [blame] | 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 | |
| 13 | set -o nounset # Catch references to undefined variables. |
| 14 | set -o pipefail # Catch non zero exit codes within pipelines. |
| 15 | set -o errexit # Catch and propagate non zero exit codes. |
| 16 | |
| 17 | # Host and target architecture validation |
| 18 | if [ "$target_arch" == "" ]; then |
Tracy Narine | 2883a86 | 2024-02-26 15:05:11 +0000 | [diff] [blame] | 19 | echo "$name: --target_arch is not set. Example usage: --target_arch=aarch64" |
James Conroy | 919ec71 | 2022-07-13 12:57:53 +0100 | [diff] [blame] | 20 | exit 1 |
| 21 | fi |
| 22 | |
John Mcloughlin | 35bae83 | 2023-07-24 11:55:13 +0100 | [diff] [blame] | 23 | if [ "$target_arch" != "aarch64" ] && [ "$target_arch" != "android64" ] && [ "$target_arch" != "x86_64" ]; then |
Tracy Narine | 2883a86 | 2024-02-26 15:05:11 +0000 | [diff] [blame] | 24 | echo "$name: --target_arch is not valid. Valid options are: aarch64, android64, x86_64" |
James Conroy | 919ec71 | 2022-07-13 12:57:53 +0100 | [diff] [blame] | 25 | exit 1 |
| 26 | fi |
| 27 | |
| 28 | if [ "$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 |
| 33 | fi |
| 34 | |
John Mcloughlin | 35bae83 | 2023-07-24 11:55:13 +0100 | [diff] [blame] | 35 | if [ "$target_arch" == "android64" ]; then |
| 36 | if [ "$HOST_ARCH" != "x86_64" ]; then |
| 37 | echo "$name: --target_arch android64 is only supported when host is x86_64" |
| 38 | exit 1 |
| 39 | fi |
| 40 | fi |
| 41 | |
James Conroy | 919ec71 | 2022-07-13 12:57:53 +0100 | [diff] [blame] | 42 | # Validation of chosen Arm NN dependencies |
Nikhil Raj | 6aed53b | 2023-05-04 09:34:46 +0100 | [diff] [blame] | 43 | if [ "$flag_tflite_classic_delegate" -eq 0 ] && [ "$flag_tflite_opaque_delegate" -eq 0 ] && [ "$flag_tflite_parser" -eq 0 ] && [ "$flag_onnx_parser" -eq 0 ]; then |
Nikhil Raj | 542c848 | 2023-04-26 16:22:10 +0100 | [diff] [blame] | 44 | echo "$name: at least one of flags --tflite-classic-delegate, --tflite-opaque-delegate, --tflite-parser or --onnx-parser must be set (or --all)." |
James Conroy | 919ec71 | 2022-07-13 12:57:53 +0100 | [diff] [blame] | 45 | exit 1 |
| 46 | fi |
| 47 | |
| 48 | # If --num-threads is set, overwrite default NUM_THREADS with user-defined value |
| 49 | if [ ! "$num_threads" -eq 0 ]; then |
| 50 | NUM_THREADS="$num_threads" |
| 51 | fi |