Imported Upstream version 1.8.0
[platform/core/ml/nnfw.git] / tests / scripts / command / prepare-model
1 #!/bin/bash
2 #
3 # Copyright (c) 2018 Samsung Electronics Co., Ltd. All Rights Reserved
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #    http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 COMMAND_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
18 INSTALL_DIR="$(dirname $(dirname $COMMAND_DIR))"
19
20 MD5_CHECK="on"
21 DOWNLOAD_MODEL="all"
22
23 function Usage()
24 {
25     echo "Usage: $0 $(basename ${BASH_SOURCE[0]}) [OPTIONS]"
26     echo ""
27     echo "Options:"
28     echo "      --ignoremd5                         Ignore MD5 check when download model files"
29     echo "      --model=(all|nnpackage|tflite)      Download test model (default=all)"
30 }
31
32 for i in "$@"
33 do
34     case $i in
35         -h|--help|help)
36             Usage
37             exit 1
38             ;;
39         --ignoremd5)
40             MD5_CHECK="off"
41             ;;
42         --model=*)
43             DOWNLOAD_MODEL=${i#*=}
44             ;;
45         *)
46             echo "Unknown option: $i"
47             exit 1
48         ;;
49     esac
50     shift
51 done
52
53 if [[ $DOWNLOAD_MODEL == "all" ]] || [[ $DOWNLOAD_MODEL == "tflite" ]]; then
54     # Download tflite models
55     $INSTALL_DIR/test/models/run_test.sh --download=on --run=off --md5=$MD5_CHECK
56 fi
57
58 if [[ $DOWNLOAD_MODEL == "all" ]] || [[ $DOWNLOAD_MODEL == "nnpackage" ]]; then
59     # Download nnpackage model
60     NNPACKAGE_CONFIG_DIR=$INSTALL_DIR/test/models/nnpackage/
61     NNPACKAGE_CACHE_DIR=$INSTALL_DIR/unittest_standalone/nnfw_api_gtest_models/
62     $INSTALL_DIR/test/models/run_test.sh --download=on --run=off --md5=$MD5_CHECK \
63         --configdir=$NNPACKAGE_CONFIG_DIR --cachedir=$NNPACKAGE_CACHE_DIR
64 fi