Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / compiler / one-cmds / tests / one-quantize_016.test
1 #!/bin/bash
2
3 # Copyright (c) 2023 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 filename_ext="$(basename -- $0)"
18 filename="${filename_ext%.*}"
19
20 # TODO Resolve circledump not found
21 # https://github.com/Samsung/ONE/issues/10550
22 if ! command -v circledump &> /dev/null
23 then
24   echo "${filename_ext} SKIPPED"
25   exit 0
26 fi
27
28 trap_err_onexit()
29 {
30   echo "${filename_ext} FAILED"
31   exit 255
32 }
33
34 trap trap_err_onexit ERR
35
36 inputfile="./reshape_matmul.circle"
37 outputfile="./reshape_matmul.one-quantize_016.circle"
38
39 rm -f ${filename}.log
40 rm -f ${filename}.first.cdump
41 rm -f ${filename}.second.cdump
42 rm -f ${outputfile}
43
44 # run test with different input_type
45 one-quantize \
46 --input_dtype float32 \
47 --quantized_dtype uint8 \
48 --granularity channel \
49 --input_type uint8,int16 \
50 --input_path ${inputfile} \
51 --output_path ${outputfile} > ${filename}.log 2>&1
52
53 if [[ ! -s "${outputfile}" ]]; then
54   trap_err_onexit
55 fi
56
57 circledump ${outputfile} | grep "T(0:0)" > ${filename}.first.cdump
58 circledump ${outputfile} | grep "T(0:1)" > ${filename}.second.cdump
59
60 # check dtype of the first input (uint8)
61 if ! grep -q "UINT8" "${filename}.first.cdump"; then
62   trap_err_onexit
63 fi
64
65 # check dtype of the second input (int16)
66 if ! grep -q "INT16" "${filename}.second.cdump"; then
67   trap_err_onexit
68 fi
69
70 echo "${filename_ext} SUCCESS"