aboutsummaryrefslogtreecommitdiff
path: root/examples/run_ref_model_examples.sh
blob: 2744bc8f83717feebbaba8d4d0536b885aea8f30 (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
#!/bin/bash -x

# Copyright (c) 2022 Arm Limited.
# SPDX-License-Identifier: Apache-2.0

# This script runs the given example networks against the TOSA
# reference model as a reference for using the reference model.

set -e

run_test()
{
   TEST=$1; shift
   FRAMEWORK=$1; shift

   echo "####  RUNNING EXAMPLE ${FRAMEWORK} ${TEST}"

   # Assumes the reference model is already built in ../build

   ../build/reference_model/tosa_reference_model \
      --test_desc=../examples/${TEST}/flatbuffer-${FRAMEWORK}/desc.json \
      --ofm_file=out.npy
    python3 -c "import sys; import numpy as np; a = np.load(sys.argv[1]); b = np.load(sys.argv[2]); sys.exit(int((a != b).all()));" \
        ../examples/${TEST}/${FRAMEWORK}_result.npy \
        ../examples/${TEST}/flatbuffer-${FRAMEWORK}/out.npy
}

run_test test_add_1x4x4x4_f32 tf
run_test test_add_1x4x4x4_f32 tflite
run_test test_conv2d_1x1_1x32x32x8_f32_st11_padSAME_dilat11 tf
run_test test_conv2d_1x1_1x32x32x8_f32_st11_padSAME_dilat11 tflite
run_test test_conv2d_1x1_1x32x32x8_qi8_st11_padSAME_dilat11 tflite