Imported Upstream version 1.7.0
[platform/core/ml/nnfw.git] / tests / nnapi / specs / skip / V1_2 / box_with_nms_limit_linear.mod.py
1 #
2 # Copyright (C) 2019 The Android Open Source Project
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #      http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 #
16
17 # TEST 1: BOX_WITH_NMS_LIMIT, score_threshold = 0.3, nms_threshold = 0.4, max_detections = -1
18 i1 = Input("scores", "TENSOR_FLOAT32", "{19, 3}") # scores
19 i2 = Input("roi", "TENSOR_FLOAT32", "{19, 12}") # roi
20 i3 = Input("batchSplit", "TENSOR_INT32", "{19}") # batchSplit
21
22 o1 = Output("scoresOut", "TENSOR_FLOAT32", "{16}") # scores out
23 o2 = Output("roiOut", "TENSOR_FLOAT32", "{16, 4}") # roi out
24 o3 = Output("classesOut", "TENSOR_INT32", "{16}") # classes out
25 o4 = Output("batchSplitOut", "TENSOR_INT32", "{16}") # batch split out
26 model = Model().Operation("BOX_WITH_NMS_LIMIT", i1, i2, i3, 0.3, -1, 1, 0.4, 1.0, 0.3).To(o1, o2, o3, o4)
27
28 quant8 = DataTypeConverter().Identify({
29     i1: ("TENSOR_QUANT8_ASYMM", 0.01, 0),
30     i2: ("TENSOR_QUANT16_ASYMM", 0.125, 0),
31     o1: ("TENSOR_QUANT8_ASYMM", 0.01, 0),
32     o2: ("TENSOR_QUANT16_ASYMM", 0.125, 0)
33 })
34
35 input0 = {
36     i1: [   # scores
37         0.90, 0.95, 0.75,
38         0.80, 0.70, 0.85,
39         0.60, 0.90, 0.95,
40         0.90, 0.65, 0.90,
41         0.80, 0.85, 0.80,
42         0.60, 0.60, 0.20,
43         0.60, 0.80, 0.40,
44         0.90, 0.55, 0.60,
45         0.90, 0.75, 0.70,
46         0.80, 0.70, 0.85,
47         0.90, 0.95, 0.75,
48         0.80, 0.85, 0.80,
49         0.60, 0.90, 0.95,
50         0.60, 0.60, 0.20,
51         0.50, 0.90, 0.80,
52         0.90, 0.75, 0.70,
53         0.90, 0.65, 0.90,
54         0.90, 0.55, 0.60,
55         0.60, 0.80, 0.40
56     ],
57     i2: [   # roi
58         1, 1, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10,
59         2, 2, 11, 11, 1, 1, 11, 11, 1, 1, 11, 11,
60         3, 3, 12, 12, 2, 2, 12, 12, 2, 2, 12, 12,
61         4, 4, 13, 13, 3, 3, 13, 13, 3, 3, 13, 13,
62         5, 5, 14, 14, 4, 4, 14, 14, 4, 4, 14, 14,
63         6, 6, 15, 15, 5, 5, 15, 15, 5, 5, 15, 15,
64         7, 7, 16, 16, 6, 6, 16, 16, 6, 6, 16, 16,
65         8, 8, 17, 17, 7, 7, 17, 17, 7, 7, 17, 17,
66         9, 9, 18, 18, 8, 8, 18, 18, 8, 8, 18, 18,
67         2, 2, 11, 11, 2, 2, 12, 12, 2, 2, 12, 12,
68         1, 1, 10, 10, 1, 1, 11, 11, 1, 1, 11, 11,
69         5, 5, 14, 14, 5, 5, 15, 15, 5, 5, 15, 15,
70         3, 3, 12, 12, 3, 3, 13, 13, 3, 3, 13, 13,
71         6, 6, 15, 15, 6, 6, 16, 16, 6, 6, 16, 16,
72         0, 0, 1,  1,  0, 0, 2,  2,  0, 0, 2,  2,
73         9, 9, 18, 18, 9, 9, 19, 19, 9, 9, 19, 19,
74         4, 4, 13, 13, 4, 4, 14, 14, 4, 4, 14, 14,
75         8, 8, 17, 17, 8, 8, 18, 18, 8, 8, 18, 18,
76         7, 7, 16, 16, 7, 7, 17, 17, 7, 7, 17, 17
77     ],
78     i3: [0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]  # batch split
79 }
80
81 output0 = {
82     o1: [
83         0.95, 0.85, 0.75, 0.95, 0.7, 0.42352945, 0.39705884,
84         0.95, 0.9, 0.85, 0.75, 0.95, 0.8, 0.7, 0.42352945, 0.39705884
85     ],
86     o2: [
87         0, 0, 10, 10,
88         4, 4, 14, 14,
89         8, 8, 18, 18,
90         2, 2, 12, 12,
91         8, 8, 18, 18,
92         4, 4, 14, 14,
93         0, 0, 10, 10,
94         1, 1, 11, 11,
95         0, 0,  2,  2,
96         5, 5, 15, 15,
97         9, 9, 19, 19,
98         3, 3, 13, 13,
99         0, 0,  2,  2,
100         9, 9, 19, 19,
101         5, 5, 15, 15,
102         1, 1, 11, 11
103     ],
104     o3: [1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2, 2],
105     o4: [0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1],
106 }
107
108 Example((input0, output0)).AddVariations("relaxed", "float16", quant8)
109
110
111 # TEST 2: BOX_WITH_NMS_LIMIT, score_threshold = 0.3, nms_threshold = 0.4, max_detections = 5
112 i1 = Input("scores", "TENSOR_FLOAT32", "{19, 3}") # scores
113 i2 = Input("roi", "TENSOR_FLOAT32", "{19, 12}") # roi
114 i3 = Input("batchSplit", "TENSOR_INT32", "{19}") # batchSplit
115
116 o1 = Output("scoresOut", "TENSOR_FLOAT32", "{15}") # scores out
117 o2 = Output("roiOut", "TENSOR_FLOAT32", "{15, 4}") # roi out
118 o3 = Output("classesOut", "TENSOR_INT32", "{15}") # classes out
119 o4 = Output("batchSplitOut", "TENSOR_INT32", "{15}") # batch split out
120 model = Model().Operation("BOX_WITH_NMS_LIMIT", i1, i2, i3, 0.3, 8, 1, 0.4, 0.5, 0.3).To(o1, o2, o3, o4)
121
122 quant8 = DataTypeConverter().Identify({
123     i1: ("TENSOR_QUANT8_ASYMM", 0.01, 128),
124     i2: ("TENSOR_QUANT16_ASYMM", 0.125, 0),
125     o1: ("TENSOR_QUANT8_ASYMM", 0.01, 128),
126     o2: ("TENSOR_QUANT16_ASYMM", 0.125, 0)
127 })
128
129 input0 = {
130     i1: [   # scores
131         0.90, 0.95, 0.75,
132         0.80, 0.70, 0.85,
133         0.60, 0.90, 0.95,
134         0.90, 0.65, 0.90,
135         0.80, 0.85, 0.80,
136         0.60, 0.60, 0.20,
137         0.60, 0.80, 0.40,
138         0.90, 0.55, 0.60,
139         0.90, 0.75, 0.70,
140         0.80, 0.70, 0.85,
141         0.90, 0.95, 0.75,
142         0.80, 0.85, 0.80,
143         0.60, 0.90, 0.95,
144         0.60, 0.60, 0.20,
145         0.50, 0.90, 0.80,
146         0.90, 0.75, 0.70,
147         0.90, 0.65, 0.90,
148         0.90, 0.55, 0.60,
149         0.60, 0.80, 0.40
150     ],
151     i2: [   # roi
152         1, 1, 10, 10, 0, 0, 10, 10, 0, 0, 10, 10,
153         2, 2, 11, 11, 1, 1, 11, 11, 1, 1, 11, 11,
154         3, 3, 12, 12, 2, 2, 12, 12, 2, 2, 12, 12,
155         4, 4, 13, 13, 3, 3, 13, 13, 3, 3, 13, 13,
156         5, 5, 14, 14, 4, 4, 14, 14, 4, 4, 14, 14,
157         6, 6, 15, 15, 5, 5, 15, 15, 5, 5, 15, 15,
158         7, 7, 16, 16, 6, 6, 16, 16, 6, 6, 16, 16,
159         8, 8, 17, 17, 7, 7, 17, 17, 7, 7, 17, 17,
160         9, 9, 18, 18, 8, 8, 18, 18, 8, 8, 18, 18,
161         2, 2, 11, 11, 2, 2, 12, 12, 2, 2, 12, 12,
162         1, 1, 10, 10, 1, 1, 11, 11, 1, 1, 11, 11,
163         5, 5, 14, 14, 5, 5, 15, 15, 5, 5, 15, 15,
164         3, 3, 12, 12, 3, 3, 13, 13, 3, 3, 13, 13,
165         6, 6, 15, 15, 6, 6, 16, 16, 6, 6, 16, 16,
166         0, 0, 1,  1,  0, 0, 2,  2,  0, 0, 2,  2,
167         9, 9, 18, 18, 9, 9, 19, 19, 9, 9, 19, 19,
168         4, 4, 13, 13, 4, 4, 14, 14, 4, 4, 14, 14,
169         8, 8, 17, 17, 8, 8, 18, 18, 8, 8, 18, 18,
170         7, 7, 16, 16, 7, 7, 17, 17, 7, 7, 17, 17
171     ],
172     i3: [1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]  # batch split
173 }
174
175 output0 = {
176     o1: [
177         0.95, 0.85, 0.75, 0.95, 0.7, 0.42352945, 0.39705884,
178         0.95, 0.9, 0.85, 0.75, 0.95, 0.8, 0.7, 0.42352945
179     ],
180     o2: [
181         0, 0, 10, 10,
182         4, 4, 14, 14,
183         8, 8, 18, 18,
184         2, 2, 12, 12,
185         8, 8, 18, 18,
186         4, 4, 14, 14,
187         0, 0, 10, 10,
188         1, 1, 11, 11,
189         0, 0,  2,  2,
190         5, 5, 15, 15,
191         9, 9, 19, 19,
192         3, 3, 13, 13,
193         0, 0,  2,  2,
194         9, 9, 19, 19,
195         5, 5, 15, 15
196     ],
197     o3: [1, 1, 1, 2, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 2],
198     o4: [1, 1, 1, 1, 1, 1, 1, 3, 3, 3, 3, 3, 3, 3, 3],
199 }
200
201 Example((input0, output0)).AddVariations("relaxed", "float16", quant8)