1#!/usr/bin/env python3
2#
3# SPDX-FileCopyrightText: Copyright 2010-2024 Arm Limited and/or its affiliates <open-source-office@arm.com>
4#
5# SPDX-License-Identifier: Apache-2.0
6#
7# Licensed under the Apache License, Version 2.0 (the License); you may
8# not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an AS IS BASIS, WITHOUT
15# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18#
19import os
20os.environ["TF_USE_LEGACY_KERAS"]="1"
21import sys
22import argparse
23
24from packaging import version
25
26from test_settings import TestSettings
27from conv_settings import ConvSettings
28from pooling_settings import PoolingSettings
29from softmax_settings import SoftmaxSettings
30from svdf_settings import SVDFSettings
31from add_mul_settings import AddMulSettings
32from lstm_settings import LSTMSettings
33from fully_connected_settings import FullyConnectedSettings
34
35import tensorflow as tf
36
37
38def parse_args() -> argparse.Namespace:
39    parser = argparse.ArgumentParser(description="Generate input and refererence output data for unittests."
40                                     " It can regenerate all data, load all stored data or a combination of it.")
41    parser.add_argument('--dataset', type=str, default=None, help="Name of generated test set.")
42    parser.add_argument('--regenerate-weights', action='store_true', help="Regenerate and store new weights.")
43    parser.add_argument('--regenerate-input', action='store_true', help="Regenerate and store new input.")
44    parser.add_argument('--regenerate-biases', action='store_true', help="Regenerate and store new biases.")
45    parser.add_argument('-a', '--regenerate-all', action='store_true', help="Regenerate and store all data.")
46    parser.add_argument('-t',
47                        '--testtype',
48                        type=str,
49                        default=None,
50                        choices=[
51                            'conv', 'depthwise_conv', 'avgpool', 'maxpool', 'fully_connected', 'softmax', 'svdf', 'add',
52                            'mul', 'lstm', 'transpose_conv'
53                        ],
54                        help='Type of test. There are the operators that have unit tests.')
55    parser.add_argument('--run-all-testsets',
56                        action='store_true',
57                        help="Run the script for all existing test "
58                        "sets. Regenerate all, partially all or no input data (output may still change, depending on"
59                        " changes in script) depending on regenerate flags. If used together with the -t flag, only"
60                        " tests of that type will be run.")
61    parser.add_argument('--schema-file', type=str, help="Path to schema file. This may be needed for some tests.")
62    parser.add_argument('--interpreter', type=str, default='tensorflow', choices=['tensorflow', 'tflite_runtime',
63                                                                                  'tflite_micro'],
64                        help="Use interpreter from tensorflow or tflite_runtime. See README for more info.")
65
66    return parser.parse_args()
67
68
69def load_testdata_sets(regenerate_input, regenerate_weights, regenerate_biases, schema_file, interpreter) -> dict:
70    """
71    Add all new testdata sets here
72    """
73    testdata_sets = {}
74
75    type_of_test = 'conv'
76    dataset = 'basic'
77    testdata_sets[dataset] = ConvSettings(dataset,
78                                          type_of_test,
79                                          regenerate_weights,
80                                          regenerate_input,
81                                          regenerate_biases,
82                                          schema_file,
83                                          in_ch=1,
84                                          out_ch=1,
85                                          x_in=5,
86                                          y_in=8,
87                                          w_x=2,
88                                          w_y=4,
89                                          stride_x=1,
90                                          stride_y=1,
91                                          pad=False,
92                                          interpreter=interpreter)
93    dataset = 'stride2pad1'
94    testdata_sets[dataset] = ConvSettings(dataset,
95                                          type_of_test,
96                                          regenerate_weights,
97                                          regenerate_input,
98                                          regenerate_biases,
99                                          schema_file,
100                                          in_ch=1,
101                                          out_ch=1,
102                                          x_in=7,
103                                          y_in=7,
104                                          w_x=3,
105                                          w_y=3,
106                                          stride_x=2,
107                                          stride_y=2,
108                                          pad=True,
109                                          interpreter=interpreter)
110    dataset = 'kernel1x1'
111    testdata_sets[dataset] = ConvSettings(dataset,
112                                          type_of_test,
113                                          regenerate_weights,
114                                          regenerate_input,
115                                          regenerate_biases,
116                                          schema_file,
117                                          in_ch=19,
118                                          out_ch=7,
119                                          x_in=7,
120                                          y_in=5,
121                                          w_x=1,
122                                          w_y=1,
123                                          stride_x=1,
124                                          stride_y=1,
125                                          pad=False,
126                                          bias_min=TestSettings.INT8_MIN,
127                                          bias_max=TestSettings.INT8_MAX,
128                                          out_activation_min=-126,
129                                          out_activation_max=127,
130                                          batches=2,
131                                          interpreter=interpreter)
132    dataset = 'kernel1x1_stride_x'
133    testdata_sets[dataset] = ConvSettings(dataset,
134                                          type_of_test,
135                                          regenerate_weights,
136                                          regenerate_input,
137                                          regenerate_biases,
138                                          schema_file,
139                                          in_ch=9,
140                                          out_ch=5,
141                                          x_in=7,
142                                          y_in=4,
143                                          w_x=1,
144                                          w_y=1,
145                                          stride_x=3,
146                                          stride_y=1,
147                                          pad=False,
148                                          out_activation_min=-126,
149                                          out_activation_max=127,
150                                          batches=2,
151                                          interpreter=interpreter)
152    dataset = 'kernel1x1_stride_x_y'
153    testdata_sets[dataset] = ConvSettings(dataset,
154                                          type_of_test,
155                                          regenerate_weights,
156                                          regenerate_input,
157                                          regenerate_biases,
158                                          schema_file,
159                                          in_ch=23,
160                                          out_ch=15,
161                                          randmin=0,
162                                          x_in=7,
163                                          y_in=6,
164                                          w_x=1,
165                                          w_y=1,
166                                          stride_x=2,
167                                          stride_y=2,
168                                          pad=False,
169                                          out_activation_min=-6,
170                                          out_activation_max=127,
171                                          batches=3,
172                                          interpreter=interpreter)
173    dataset = 'kernel1x1_stride_x_y_1'
174    testdata_sets[dataset] = ConvSettings(dataset,
175                                          type_of_test,
176                                          regenerate_weights,
177                                          regenerate_input,
178                                          regenerate_biases,
179                                          schema_file,
180                                          in_ch=5,
181                                          out_ch=5,
182                                          x_in=4,
183                                          y_in=4,
184                                          w_x=1,
185                                          w_y=1,
186                                          stride_x=2,
187                                          stride_y=2,
188                                          pad=False,
189                                          out_activation_min=-126,
190                                          out_activation_max=127,
191                                          batches=2,
192                                          interpreter=interpreter)
193    dataset = 'kernel1x1_stride_x_y_2'
194    testdata_sets[dataset] = ConvSettings(dataset,
195                                          type_of_test,
196                                          regenerate_weights,
197                                          regenerate_input,
198                                          regenerate_biases,
199                                          schema_file,
200                                          in_ch=5,
201                                          out_ch=5,
202                                          x_in=4,
203                                          y_in=4,
204                                          w_x=1,
205                                          w_y=1,
206                                          stride_x=3,
207                                          stride_y=3,
208                                          pad=False,
209                                          out_activation_min=-126,
210                                          out_activation_max=127,
211                                          batches=2,
212                                          interpreter=interpreter)
213    dataset = 'conv_3'
214    testdata_sets[dataset] = ConvSettings(dataset,
215                                          type_of_test,
216                                          regenerate_weights,
217                                          regenerate_input,
218                                          regenerate_biases,
219                                          schema_file,
220                                          in_ch=3,
221                                          out_ch=1,
222                                          x_in=10,
223                                          y_in=49,
224                                          w_x=4,
225                                          w_y=10,
226                                          stride_x=1,
227                                          stride_y=2,
228                                          pad=True,
229                                          out_activation_min=-127,
230                                          out_activation_max=127,
231                                          interpreter=interpreter)
232    dataset = 'conv_1_x_n_1'  # left and right pad, no non-padded elements
233    testdata_sets[dataset] = ConvSettings(dataset,
234                                          type_of_test,
235                                          regenerate_weights,
236                                          regenerate_input,
237                                          regenerate_biases,
238                                          schema_file,
239                                          in_ch=4,
240                                          out_ch=3,
241                                          x_in=2,
242                                          y_in=1,
243                                          w_x=3,
244                                          w_y=1,
245                                          stride_x=1,
246                                          stride_y=1,
247                                          pad=True,
248                                          out_activation_min=-127,
249                                          out_activation_max=127,
250                                          batches=2,
251                                          interpreter=interpreter)
252    dataset = 'conv_1_x_n_2'  # no pad
253    testdata_sets[dataset] = ConvSettings(dataset,
254                                          type_of_test,
255                                          regenerate_weights,
256                                          regenerate_input,
257                                          regenerate_biases,
258                                          schema_file,
259                                          in_ch=4,
260                                          out_ch=3,
261                                          x_in=296,
262                                          y_in=1,
263                                          w_x=48,
264                                          w_y=1,
265                                          stride_x=2,
266                                          stride_y=1,
267                                          pad=False,
268                                          out_activation_min=-111,
269                                          out_activation_max=127,
270                                          interpreter=interpreter)
271    dataset = 'conv_1_x_n_3'
272    testdata_sets[dataset] = ConvSettings(dataset,
273                                          type_of_test,
274                                          regenerate_weights,
275                                          regenerate_input,
276                                          regenerate_biases,
277                                          schema_file,
278                                          in_ch=4,
279                                          out_ch=1,
280                                          x_in=296,
281                                          y_in=1,
282                                          w_x=48,
283                                          w_y=1,
284                                          stride_x=2,
285                                          stride_y=1,
286                                          pad=True,
287                                          out_activation_min=-111,
288                                          out_activation_max=127,
289                                          interpreter=interpreter)
290    dataset = 'conv_1_x_n_4'  # 0 left pad, 1 right pad
291    testdata_sets[dataset] = ConvSettings(dataset,
292                                          type_of_test,
293                                          regenerate_weights,
294                                          regenerate_input,
295                                          regenerate_biases,
296                                          schema_file,
297                                          in_ch=4,
298                                          out_ch=4,
299                                          x_in=16,
300                                          y_in=1,
301                                          w_x=3,
302                                          w_y=1,
303                                          stride_x=2,
304                                          stride_y=1,
305                                          pad=True,
306                                          out_activation_min=-88,
307                                          out_activation_max=127,
308                                          interpreter=interpreter)
309    dataset = 'conv_1_x_n_5'
310    testdata_sets[dataset] = ConvSettings(dataset,
311                                          type_of_test,
312                                          regenerate_weights,
313                                          regenerate_input,
314                                          regenerate_biases,
315                                          schema_file,
316                                          in_ch=4,
317                                          out_ch=1,
318                                          x_in=17,
319                                          y_in=1,
320                                          w_x=3,
321                                          w_y=1,
322                                          stride_x=3,
323                                          stride_y=1,
324                                          pad=True,
325                                          out_activation_min=-88,
326                                          out_activation_max=127,
327                                          interpreter=interpreter)
328    dataset = 'conv_1_x_n_6_generic'  # right_pad_num + no_pad_num + left_pad_num != output_x
329    testdata_sets[dataset] = ConvSettings(dataset,
330                                          type_of_test,
331                                          regenerate_weights,
332                                          regenerate_input,
333                                          regenerate_biases,
334                                          schema_file,
335                                          in_ch=1,
336                                          out_ch=16,
337                                          x_in=4,
338                                          y_in=1,
339                                          w_x=8,
340                                          w_y=1,
341                                          stride_x=4,
342                                          stride_y=1,
343                                          pad=True,
344                                          out_activation_min=-125,
345                                          out_activation_max=126,
346                                          interpreter=interpreter)
347    dataset = 'conv_1_x_n_7'
348    testdata_sets[dataset] = ConvSettings(dataset,
349                                          type_of_test,
350                                          regenerate_weights,
351                                          regenerate_input,
352                                          regenerate_biases,
353                                          schema_file,
354                                          in_ch=20,
355                                          out_ch=15,
356                                          x_in=148,
357                                          y_in=1,
358                                          w_x=32,
359                                          w_y=1,
360                                          stride_x=1,
361                                          stride_y=1,
362                                          pad=True,
363                                          out_activation_min=-127,
364                                          out_activation_max=127,
365                                          batches=2,
366                                          interpreter=interpreter)
367    dataset = 'conv_1_x_n_8'
368    testdata_sets[dataset] = ConvSettings(dataset,
369                                          type_of_test,
370                                          regenerate_weights,
371                                          regenerate_input,
372                                          regenerate_biases,
373                                          schema_file,
374                                          in_ch=12,
375                                          out_ch=10,
376                                          x_in=148,
377                                          y_in=1,
378                                          w_x=48,
379                                          w_y=1,
380                                          stride_x=2,
381                                          stride_y=1,
382                                          pad=True,
383                                          out_activation_min=-127,
384                                          out_activation_max=127,
385                                          batches=2,
386                                          interpreter=interpreter)
387    dataset = 'conv_2'
388    testdata_sets[dataset] = ConvSettings(dataset,
389                                          type_of_test,
390                                          regenerate_weights,
391                                          regenerate_input,
392                                          regenerate_biases,
393                                          schema_file,
394                                          in_ch=2,
395                                          out_ch=4,
396                                          x_in=6,
397                                          y_in=3,
398                                          w_x=3,
399                                          w_y=3,
400                                          stride_x=1,
401                                          stride_y=1,
402                                          pad=True,
403                                          out_activation_min=-101,
404                                          out_activation_max=127,
405                                          interpreter=interpreter)
406    dataset = 'conv_4'  # batches > 2
407    testdata_sets[dataset] = ConvSettings(dataset,
408                                          type_of_test,
409                                          regenerate_weights,
410                                          regenerate_input,
411                                          regenerate_biases,
412                                          schema_file,
413                                          in_ch=3,
414                                          out_ch=3,
415                                          x_in=5,
416                                          y_in=5,
417                                          w_x=2,
418                                          w_y=3,
419                                          stride_x=2,
420                                          stride_y=2,
421                                          pad=False,
422                                          out_activation_min=-109,
423                                          out_activation_max=127,
424                                          batches=3,
425                                          interpreter=interpreter)
426    dataset = 'conv_5'
427    testdata_sets[dataset] = ConvSettings(dataset,
428                                          type_of_test,
429                                          regenerate_weights,
430                                          regenerate_input,
431                                          regenerate_biases,
432                                          schema_file,
433                                          in_ch=128,
434                                          out_ch=1,
435                                          x_in=128,
436                                          y_in=1,
437                                          w_x=3,
438                                          w_y=3,
439                                          stride_x=4,
440                                          stride_y=4,
441                                          pad=True,
442                                          out_activation_min=-88,
443                                          out_activation_max=127,
444                                          interpreter=interpreter)
445    dataset = 'conv_out_activation'
446    testdata_sets[dataset] = ConvSettings(dataset,
447                                          type_of_test,
448                                          regenerate_weights,
449                                          regenerate_input,
450                                          regenerate_biases,
451                                          schema_file,
452                                          in_ch=4,
453                                          out_ch=2,
454                                          x_in=3,
455                                          y_in=3,
456                                          w_x=3,
457                                          w_y=3,
458                                          stride_x=1,
459                                          stride_y=1,
460                                          pad=True,
461                                          out_activation_min=-61,
462                                          out_activation_max=107,
463                                          interpreter=interpreter)
464    dataset = 'conv_dilation_golden'
465    testdata_sets[dataset] = ConvSettings(dataset,
466                                          type_of_test,
467                                          regenerate_weights,
468                                          regenerate_input,
469                                          regenerate_biases,
470                                          schema_file,
471                                          in_ch=1,
472                                          batches=2,
473                                          out_ch=3,
474                                          x_in=6,
475                                          y_in=4,
476                                          w_x=2,
477                                          w_y=2,
478                                          stride_x=1,
479                                          stride_y=1,
480                                          pad=True,
481                                          out_activation_min=-128,
482                                          out_activation_max=127,
483                                          dilation_x=3,
484                                          dilation_y=2,
485                                          interpreter=interpreter)
486    dataset = 'conv_2x2_dilation'
487    testdata_sets[dataset] = ConvSettings(dataset,
488                                          type_of_test,
489                                          regenerate_weights,
490                                          regenerate_input,
491                                          regenerate_biases,
492                                          schema_file,
493                                          in_ch=2,
494                                          out_ch=2,
495                                          x_in=10,
496                                          y_in=10,
497                                          w_x=3,
498                                          w_y=3,
499                                          stride_x=1,
500                                          stride_y=1,
501                                          pad=False,
502                                          out_activation_min=-61,
503                                          out_activation_max=107,
504                                          dilation_x=2,
505                                          dilation_y=2,
506                                          interpreter=interpreter)
507    dataset = 'conv_2x3_dilation'
508    testdata_sets[dataset] = ConvSettings(dataset,
509                                          type_of_test,
510                                          regenerate_weights,
511                                          regenerate_input,
512                                          regenerate_biases,
513                                          schema_file,
514                                          in_ch=2,
515                                          out_ch=2,
516                                          x_in=3,
517                                          y_in=3,
518                                          w_x=3,
519                                          w_y=3,
520                                          stride_x=1,
521                                          stride_y=1,
522                                          pad=True,
523                                          out_activation_min=-61,
524                                          out_activation_max=107,
525                                          dilation_x=2,
526                                          dilation_y=2,
527                                          interpreter=interpreter)
528    dataset = 'conv_3x2_dilation'
529    testdata_sets[dataset] = ConvSettings(dataset,
530                                          type_of_test,
531                                          regenerate_weights,
532                                          regenerate_input,
533                                          regenerate_biases,
534                                          schema_file,
535                                          in_ch=2,
536                                          out_ch=2,
537                                          x_in=3,
538                                          y_in=3,
539                                          w_x=3,
540                                          w_y=3,
541                                          stride_x=1,
542                                          stride_y=1,
543                                          pad=True,
544                                          out_activation_min=-61,
545                                          out_activation_max=107,
546                                          dilation_x=3,
547                                          dilation_y=2,
548                                          interpreter=interpreter)
549    dataset = 'conv_2x2_dilation_5x5_input'
550    testdata_sets[dataset] = ConvSettings(dataset,
551                                          type_of_test,
552                                          regenerate_weights,
553                                          regenerate_input,
554                                          regenerate_biases,
555                                          schema_file,
556                                          in_ch=2,
557                                          out_ch=2,
558                                          x_in=5,
559                                          y_in=5,
560                                          w_x=3,
561                                          w_y=3,
562                                          stride_x=1,
563                                          stride_y=1,
564                                          pad=True,
565                                          out_activation_min=-61,
566                                          out_activation_max=107,
567                                          dilation_x=2,
568                                          dilation_y=2,
569                                          interpreter=interpreter)
570    dataset = 'conv_3x3_dilation_5x5_input'
571    testdata_sets[dataset] = ConvSettings(dataset,
572                                          type_of_test,
573                                          regenerate_weights,
574                                          regenerate_input,
575                                          regenerate_biases,
576                                          schema_file,
577                                          in_ch=2,
578                                          out_ch=2,
579                                          x_in=9,
580                                          y_in=11,
581                                          w_x=3,
582                                          w_y=3,
583                                          stride_x=1,
584                                          stride_y=1,
585                                          pad=True,
586                                          out_activation_min=-61,
587                                          out_activation_max=107,
588                                          dilation_x=2,
589                                          dilation_y=2,
590                                          interpreter=interpreter)
591    dataset = 'int16xint8'
592    testdata_sets[dataset] = ConvSettings(dataset,
593                                          type_of_test,
594                                          regenerate_weights,
595                                          regenerate_input,
596                                          regenerate_biases,
597                                          schema_file,
598                                          in_ch=55,
599                                          out_ch=4,
600                                          x_in=10,
601                                          y_in=8,
602                                          w_x=9,
603                                          w_y=4,
604                                          stride_x=1,
605                                          stride_y=1,
606                                          pad=False,
607                                          generate_bias=False,
608                                          randmin=TestSettings.INT16_MIN,
609                                          randmax=TestSettings.INT16_MAX,
610                                          out_activation_min=TestSettings.INT16_MIN,
611                                          out_activation_max=TestSettings.INT16_MAX,
612                                          int16xint8=True,
613                                          interpreter=interpreter)
614    dataset = 'int16xint8_spill'
615    testdata_sets[dataset] = ConvSettings(dataset,
616                                          type_of_test,
617                                          regenerate_weights,
618                                          regenerate_input,
619                                          regenerate_biases,
620                                          schema_file,
621                                          in_ch=55,
622                                          out_ch=9,
623                                          x_in=10,
624                                          y_in=8,
625                                          w_x=9,
626                                          w_y=4,
627                                          stride_x=1,
628                                          stride_y=1,
629                                          pad=False,
630                                          generate_bias=False,
631                                          randmin=TestSettings.INT16_MAX - 100,
632                                          randmax=TestSettings.INT16_MAX,
633                                          out_activation_min=TestSettings.INT16_MAX - 100,
634                                          out_activation_max=TestSettings.INT16_MAX,
635                                          bias_min=TestSettings.INT64_MIN,
636                                          bias_max=TestSettings.INT64_MAX,
637                                          int16xint8=True,
638                                          interpreter=interpreter,
639                                          weights_min=100)
640    dataset = 'int16xint8_spill2'
641    testdata_sets[dataset] = ConvSettings(dataset,
642                                          type_of_test,
643                                          regenerate_weights,
644                                          regenerate_input,
645                                          regenerate_biases,
646                                          schema_file,
647                                          in_ch=12,
648                                          out_ch=9,
649                                          x_in=10,
650                                          y_in=8,
651                                          w_x=9,
652                                          w_y=4,
653                                          stride_x=1,
654                                          stride_y=1,
655                                          pad=False,
656                                          generate_bias=False,
657                                          randmin=TestSettings.INT16_MAX - 100,
658                                          randmax=TestSettings.INT16_MAX,
659                                          out_activation_min=TestSettings.INT16_MAX - 100,
660                                          out_activation_max=TestSettings.INT16_MAX,
661                                          bias_min=TestSettings.INT64_MIN,
662                                          bias_max=TestSettings.INT64_MAX,
663                                          int16xint8=True,
664                                          interpreter=interpreter,
665                                          weights_min=100)
666    dataset = 'requantize_s64'
667    testdata_sets[dataset] = ConvSettings(dataset,
668                                          type_of_test,
669                                          regenerate_weights,
670                                          regenerate_input,
671                                          regenerate_biases,
672                                          schema_file,
673                                          in_ch=8,
674                                          out_ch=8,
675                                          x_in=4,
676                                          y_in=4,
677                                          w_x=2,
678                                          w_y=2,
679                                          stride_x=1,
680                                          stride_y=1,
681                                          pad=False,
682                                          generate_bias=True,
683                                          out_activation_min=TestSettings.INT16_MIN,
684                                          out_activation_max=TestSettings.INT16_MAX,
685                                          int16xint8=True,
686                                          bias_min=-0x300,
687                                          bias_max=TestSettings.INT32_MAX + 1000,
688                                          interpreter=interpreter)
689    dataset = 'int16xint8_dilation_1'
690    testdata_sets[dataset] = ConvSettings(dataset,
691                                          type_of_test,
692                                          regenerate_weights,
693                                          regenerate_input,
694                                          regenerate_biases,
695                                          schema_file,
696                                          in_ch=2,
697                                          out_ch=2,
698                                          x_in=32,
699                                          y_in=32,
700                                          w_x=2,
701                                          w_y=2,
702                                          stride_x=1,
703                                          stride_y=1,
704                                          pad=False,
705                                          out_activation_min=TestSettings.INT16_MIN,
706                                          out_activation_max=TestSettings.INT16_MAX,
707                                          int16xint8=True,
708                                          bias_min=-0x300,
709                                          dilation_x=2,
710                                          dilation_y=2,
711                                          interpreter=interpreter)
712    dataset = 'int16xint8_dilation_2'
713    testdata_sets[dataset] = ConvSettings(dataset,
714                                          type_of_test,
715                                          regenerate_weights,
716                                          regenerate_input,
717                                          regenerate_biases,
718                                          schema_file,
719                                          in_ch=3,
720                                          out_ch=4,
721                                          x_in=7,
722                                          y_in=8,
723                                          w_x=2,
724                                          w_y=4,
725                                          stride_x=1,
726                                          stride_y=1,
727                                          pad=True,
728                                          randmin=TestSettings.INT16_MIN,
729                                          randmax=TestSettings.INT16_MAX,
730                                          out_activation_min=-13335,
731                                          out_activation_max=32767,
732                                          int16xint8=True,
733                                          dilation_x=2,
734                                          dilation_y=2,
735                                          interpreter=interpreter)
736    dataset = 'int16xint8_dilation_3'
737    testdata_sets[dataset] = ConvSettings(dataset,
738                                          type_of_test,
739                                          regenerate_weights,
740                                          regenerate_input,
741                                          regenerate_biases,
742                                          schema_file,
743                                          in_ch=3,
744                                          out_ch=4,
745                                          x_in=7,
746                                          y_in=8,
747                                          w_x=2,
748                                          w_y=4,
749                                          stride_x=1,
750                                          stride_y=1,
751                                          pad=True,
752                                          randmin=TestSettings.INT16_MIN,
753                                          randmax=TestSettings.INT16_MAX,
754                                          out_activation_min=-13335,
755                                          out_activation_max=32767,
756                                          int16xint8=True,
757                                          dilation_x=2,
758                                          interpreter=interpreter)
759    dataset = 'int16xint8xint32_1'
760    testdata_sets[dataset] = ConvSettings(dataset,
761                                          type_of_test,
762                                          regenerate_weights,
763                                          regenerate_input,
764                                          regenerate_biases,
765                                          schema_file,
766                                          in_ch=55,
767                                          out_ch=4,
768                                          x_in=10,
769                                          y_in=8,
770                                          w_x=9,
771                                          w_y=4,
772                                          stride_x=1,
773                                          stride_y=1,
774                                          pad=False,
775                                          generate_bias=False,
776                                          randmin=TestSettings.INT16_MIN,
777                                          randmax=TestSettings.INT16_MAX,
778                                          out_activation_min=TestSettings.INT16_MIN,
779                                          out_activation_max=TestSettings.INT16_MAX,
780                                          int16xint8=True,
781                                          int16xint8_int32=True,
782                                          interpreter=interpreter)
783    dataset = 'int16xint8xint32_2'
784    testdata_sets[dataset] = ConvSettings(dataset,
785                                          type_of_test,
786                                          regenerate_weights,
787                                          regenerate_input,
788                                          regenerate_biases,
789                                          schema_file,
790                                          in_ch=55,
791                                          out_ch=9,
792                                          x_in=10,
793                                          y_in=8,
794                                          w_x=9,
795                                          w_y=4,
796                                          stride_x=1,
797                                          stride_y=1,
798                                          pad=False,
799                                          generate_bias=False,
800                                          randmin=TestSettings.INT16_MAX - 100,
801                                          randmax=TestSettings.INT16_MAX,
802                                          out_activation_min=TestSettings.INT16_MAX - 100,
803                                          out_activation_max=TestSettings.INT16_MAX,
804                                          bias_min=TestSettings.INT64_MIN,
805                                          bias_max=TestSettings.INT64_MAX,
806                                          int16xint8=True,
807                                          int16xint8_int32=True,
808                                          interpreter=interpreter,
809                                          weights_min=100)
810    dataset = 'int16xint8xint32_3'
811    testdata_sets[dataset] = ConvSettings(dataset,
812                                          type_of_test,
813                                          regenerate_weights,
814                                          regenerate_input,
815                                          regenerate_biases,
816                                          schema_file,
817                                          in_ch=8,
818                                          out_ch=8,
819                                          x_in=4,
820                                          y_in=4,
821                                          w_x=2,
822                                          w_y=2,
823                                          stride_x=1,
824                                          stride_y=1,
825                                          pad=False,
826                                          generate_bias=True,
827                                          out_activation_min=TestSettings.INT16_MIN,
828                                          out_activation_max=TestSettings.INT16_MAX,
829                                          int16xint8=True,
830                                          int16xint8_int32=True,
831                                          bias_min=-0x300,
832                                          bias_max=TestSettings.INT32_MAX + 1000,
833                                          interpreter=interpreter)
834    dataset = 'int16xint8xint32_4'
835    testdata_sets[dataset] = ConvSettings(dataset,
836                                          type_of_test,
837                                          regenerate_weights,
838                                          regenerate_input,
839                                          regenerate_biases,
840                                          schema_file,
841                                          in_ch=2,
842                                          out_ch=2,
843                                          x_in=32,
844                                          y_in=32,
845                                          w_x=2,
846                                          w_y=2,
847                                          stride_x=1,
848                                          stride_y=1,
849                                          pad=False,
850                                          out_activation_min=TestSettings.INT16_MIN,
851                                          out_activation_max=TestSettings.INT16_MAX,
852                                          int16xint8=True,
853                                          int16xint8_int32=True,
854                                          bias_min=-0x300,
855                                          dilation_x=2,
856                                          dilation_y=2,
857                                          interpreter=interpreter)
858    dataset = 'int16xint8xint32_5'
859    testdata_sets[dataset] = ConvSettings(dataset,
860                                          type_of_test,
861                                          regenerate_weights,
862                                          regenerate_input,
863                                          regenerate_biases,
864                                          schema_file,
865                                          in_ch=3,
866                                          out_ch=4,
867                                          x_in=7,
868                                          y_in=8,
869                                          w_x=2,
870                                          w_y=4,
871                                          stride_x=1,
872                                          stride_y=1,
873                                          pad=True,
874                                          randmin=TestSettings.INT16_MIN,
875                                          randmax=TestSettings.INT16_MAX,
876                                          out_activation_min=-13335,
877                                          out_activation_max=32767,
878                                          int16xint8=True,
879                                          int16xint8_int32=True,
880                                          dilation_x=2,
881                                          dilation_y=2,
882                                          interpreter=interpreter)
883    dataset = 'int16xint8xint32_6'
884    testdata_sets[dataset] = ConvSettings(dataset,
885                                          type_of_test,
886                                          regenerate_weights,
887                                          regenerate_input,
888                                          regenerate_biases,
889                                          schema_file,
890                                          in_ch=3,
891                                          out_ch=4,
892                                          x_in=7,
893                                          y_in=8,
894                                          w_x=2,
895                                          w_y=4,
896                                          stride_x=1,
897                                          stride_y=1,
898                                          pad=True,
899                                          randmin=TestSettings.INT16_MIN,
900                                          randmax=TestSettings.INT16_MAX,
901                                          out_activation_min=-13335,
902                                          out_activation_max=32767,
903                                          int16xint8=True,
904                                          int16xint8_int32=True,
905                                          dilation_x=2,
906                                          interpreter=interpreter)
907    dataset = 'grouped_conv_1'
908    testdata_sets[dataset] = ConvSettings(dataset,
909                                          type_of_test,
910                                          regenerate_weights,
911                                          regenerate_input,
912                                          regenerate_biases,
913                                          schema_file,
914                                          in_ch=2,
915                                          out_ch=6,
916                                          groups=2,
917                                          x_in=5,
918                                          y_in=5,
919                                          w_x=2,
920                                          w_y=2,
921                                          generate_bias=False,
922                                          stride_x=1,
923                                          stride_y=1,
924                                          pad=False,
925                                          batches=2,
926                                          interpreter=interpreter)
927    dataset = 'grouped_conv_2'
928    testdata_sets[dataset] = ConvSettings(dataset,
929                                          type_of_test,
930                                          regenerate_weights,
931                                          regenerate_input,
932                                          regenerate_biases,
933                                          schema_file,
934                                          in_ch=4,
935                                          out_ch=2,
936                                          groups=2,
937                                          x_in=7,
938                                          y_in=3,
939                                          w_x=1,
940                                          w_y=2,
941                                          generate_bias=True,
942                                          stride_x=1,
943                                          stride_y=1,
944                                          pad=False,
945                                          interpreter=interpreter)
946    dataset = 'grouped_conv_3'
947    testdata_sets[dataset] = ConvSettings(dataset,
948                                          type_of_test,
949                                          regenerate_weights,
950                                          regenerate_input,
951                                          regenerate_biases,
952                                          schema_file,
953                                          in_ch=2,
954                                          out_ch=4,
955                                          groups=2,
956                                          x_in=3,
957                                          y_in=2,
958                                          w_x=3,
959                                          w_y=2,
960                                          generate_bias=True,
961                                          stride_x=2,
962                                          stride_y=2,
963                                          pad=True,
964                                          batches=2,
965                                          interpreter=interpreter)
966    dataset = 'grouped_conv_4'
967    testdata_sets[dataset] = ConvSettings(dataset,
968                                          type_of_test,
969                                          regenerate_weights,
970                                          regenerate_input,
971                                          regenerate_biases,
972                                          schema_file,
973                                          in_ch=3,
974                                          out_ch=6,
975                                          groups=3,
976                                          x_in=9,
977                                          y_in=9,
978                                          w_x=2,
979                                          w_y=2,
980                                          generate_bias=True,
981                                          stride_x=1,
982                                          stride_y=1,
983                                          dilation_x=3,
984                                          dilation_y=3,
985                                          pad=True,
986                                          interpreter=interpreter)
987    dataset = 'basic_int4'
988    testdata_sets[dataset] = ConvSettings(dataset,
989                                          type_of_test,
990                                          regenerate_weights,
991                                          regenerate_input,
992                                          regenerate_biases,
993                                          schema_file,
994                                          in_ch=1,
995                                          out_ch=1,
996                                          x_in=5,
997                                          y_in=8,
998                                          w_x=2,
999                                          w_y=4,
1000                                          stride_x=1,
1001                                          stride_y=1,
1002                                          pad=False,
1003                                          interpreter=interpreter,
1004                                          int4_weights=True)
1005    dataset = 'basic_2_int4'
1006    testdata_sets[dataset] = ConvSettings(dataset,
1007                                          type_of_test,
1008                                          regenerate_weights,
1009                                          regenerate_input,
1010                                          regenerate_biases,
1011                                          schema_file,
1012                                          in_ch=5,
1013                                          out_ch=15,
1014                                          x_in=15,
1015                                          y_in=15,
1016                                          w_x=5,
1017                                          w_y=5,
1018                                          stride_x=1,
1019                                          stride_y=1,
1020                                          pad=False,
1021                                          interpreter=interpreter,
1022                                          int4_weights=True)
1023    dataset = 'stride2pad1_int4'
1024    testdata_sets[dataset] = ConvSettings(dataset,
1025                                          type_of_test,
1026                                          regenerate_weights,
1027                                          regenerate_input,
1028                                          regenerate_biases,
1029                                          schema_file,
1030                                          in_ch=1,
1031                                          out_ch=1,
1032                                          x_in=7,
1033                                          y_in=7,
1034                                          w_x=3,
1035                                          w_y=3,
1036                                          stride_x=2,
1037                                          stride_y=2,
1038                                          pad=True,
1039                                          interpreter=interpreter,
1040                                          int4_weights=True)
1041
1042    dataset = 'kernel1x1_int4'
1043    testdata_sets[dataset] = ConvSettings(dataset,
1044                                          type_of_test,
1045                                          regenerate_weights,
1046                                          regenerate_input,
1047                                          regenerate_biases,
1048                                          schema_file,
1049                                          in_ch=19,
1050                                          out_ch=7,
1051                                          x_in=7,
1052                                          y_in=5,
1053                                          w_x=1,
1054                                          w_y=1,
1055                                          stride_x=1,
1056                                          stride_y=1,
1057                                          pad=False,
1058                                          bias_min=TestSettings.INT8_MIN,
1059                                          bias_max=TestSettings.INT8_MAX,
1060                                          out_activation_min=-126,
1061                                          out_activation_max=127,
1062                                          batches=2,
1063                                          interpreter=interpreter,
1064                                          int4_weights=True,
1065                                          generate_bias=False)
1066
1067    dataset = 'kernel1x1_int4_2'
1068    testdata_sets[dataset] = ConvSettings(dataset,
1069                                          type_of_test,
1070                                          regenerate_weights,
1071                                          regenerate_input,
1072                                          regenerate_biases,
1073                                          schema_file,
1074                                          in_ch=60,
1075                                          out_ch=60,
1076                                          x_in=60,
1077                                          y_in=1,
1078                                          w_x=1,
1079                                          w_y=1,
1080                                          stride_x=1,
1081                                          stride_y=1,
1082                                          pad=False,
1083                                          bias_min=TestSettings.INT8_MIN,
1084                                          bias_max=TestSettings.INT8_MAX,
1085                                          out_activation_min=-126,
1086                                          out_activation_max=127,
1087                                          batches=1,
1088                                          interpreter=interpreter,
1089                                          int4_weights=True)
1090
1091    dataset = 'kernel1x1_int4_3'
1092    testdata_sets[dataset] = ConvSettings(dataset,
1093                                          type_of_test,
1094                                          regenerate_weights,
1095                                          regenerate_input,
1096                                          regenerate_biases,
1097                                          schema_file,
1098                                          in_ch=18,
1099                                          out_ch=47,
1100                                          x_in=43,
1101                                          y_in=1,
1102                                          w_x=1,
1103                                          w_y=1,
1104                                          stride_x=1,
1105                                          stride_y=1,
1106                                          pad=False,
1107                                          bias_min=TestSettings.INT8_MIN,
1108                                          bias_max=TestSettings.INT8_MAX,
1109                                          out_activation_min=-126,
1110                                          out_activation_max=127,
1111                                          batches=1,
1112                                          interpreter=interpreter,
1113                                          int4_weights=True)
1114
1115    dataset = 'kernel1x1_stride_x_int4'
1116    testdata_sets[dataset] = ConvSettings(dataset,
1117                                          type_of_test,
1118                                          regenerate_weights,
1119                                          regenerate_input,
1120                                          regenerate_biases,
1121                                          schema_file,
1122                                          in_ch=9,
1123                                          out_ch=5,
1124                                          x_in=7,
1125                                          y_in=4,
1126                                          w_x=1,
1127                                          w_y=1,
1128                                          stride_x=3,
1129                                          stride_y=1,
1130                                          pad=False,
1131                                          out_activation_min=-126,
1132                                          out_activation_max=127,
1133                                          batches=2,
1134                                          interpreter=interpreter,
1135                                          int4_weights=True)
1136    dataset = 'kernel1x1_stride_x_y_int4'
1137    testdata_sets[dataset] = ConvSettings(dataset,
1138                                          type_of_test,
1139                                          regenerate_weights,
1140                                          regenerate_input,
1141                                          regenerate_biases,
1142                                          schema_file,
1143                                          in_ch=23,
1144                                          out_ch=15,
1145                                          randmin=0,
1146                                          x_in=7,
1147                                          y_in=6,
1148                                          w_x=1,
1149                                          w_y=1,
1150                                          stride_x=2,
1151                                          stride_y=2,
1152                                          pad=False,
1153                                          out_activation_min=-6,
1154                                          out_activation_max=127,
1155                                          batches=3,
1156                                          interpreter=interpreter,
1157                                          int4_weights=True)
1158    dataset = 'kernel1x1_stride_x_y_1_int4'
1159    testdata_sets[dataset] = ConvSettings(dataset,
1160                                          type_of_test,
1161                                          regenerate_weights,
1162                                          regenerate_input,
1163                                          regenerate_biases,
1164                                          schema_file,
1165                                          in_ch=5,
1166                                          out_ch=5,
1167                                          x_in=4,
1168                                          y_in=4,
1169                                          w_x=1,
1170                                          w_y=1,
1171                                          stride_x=2,
1172                                          stride_y=2,
1173                                          pad=False,
1174                                          out_activation_min=-126,
1175                                          out_activation_max=127,
1176                                          batches=2,
1177                                          interpreter=interpreter,
1178                                          int4_weights=True,
1179                                          generate_bias=False)
1180    dataset = 'kernel1x1_stride_x_y_2_int4'
1181    testdata_sets[dataset] = ConvSettings(dataset,
1182                                          type_of_test,
1183                                          regenerate_weights,
1184                                          regenerate_input,
1185                                          regenerate_biases,
1186                                          schema_file,
1187                                          in_ch=5,
1188                                          out_ch=5,
1189                                          x_in=4,
1190                                          y_in=4,
1191                                          w_x=1,
1192                                          w_y=1,
1193                                          stride_x=3,
1194                                          stride_y=3,
1195                                          pad=False,
1196                                          out_activation_min=-126,
1197                                          out_activation_max=127,
1198                                          batches=2,
1199                                          interpreter=interpreter,
1200                                          int4_weights=True)
1201
1202    dataset = 'conv_3_int4'
1203    testdata_sets[dataset] = ConvSettings(dataset,
1204                                          type_of_test,
1205                                          regenerate_weights,
1206                                          regenerate_input,
1207                                          regenerate_biases,
1208                                          schema_file,
1209                                          in_ch=3,
1210                                          out_ch=1,
1211                                          x_in=10,
1212                                          y_in=49,
1213                                          w_x=4,
1214                                          w_y=10,
1215                                          stride_x=1,
1216                                          stride_y=2,
1217                                          pad=True,
1218                                          out_activation_min=-127,
1219                                          out_activation_max=127,
1220                                          interpreter=interpreter,
1221                                          int4_weights=True,
1222                                          generate_bias=False)
1223
1224    dataset = 'conv_1_x_n_1_int4'  # left and right pad, no non-padded elements
1225    testdata_sets[dataset] = ConvSettings(dataset,
1226                                          type_of_test,
1227                                          regenerate_weights,
1228                                          regenerate_input,
1229                                          regenerate_biases,
1230                                          schema_file,
1231                                          in_ch=4,
1232                                          out_ch=3,
1233                                          x_in=2,
1234                                          y_in=1,
1235                                          w_x=3,
1236                                          w_y=1,
1237                                          stride_x=1,
1238                                          stride_y=1,
1239                                          pad=True,
1240                                          out_activation_min=-127,
1241                                          out_activation_max=127,
1242                                          batches=2,
1243                                          interpreter=interpreter,
1244                                          int4_weights=True)
1245    dataset = 'conv_1_x_n_2_int4'  # no pad
1246    testdata_sets[dataset] = ConvSettings(dataset,
1247                                          type_of_test,
1248                                          regenerate_weights,
1249                                          regenerate_input,
1250                                          regenerate_biases,
1251                                          schema_file,
1252                                          in_ch=4,
1253                                          out_ch=3,
1254                                          x_in=296,
1255                                          y_in=1,
1256                                          w_x=48,
1257                                          w_y=1,
1258                                          stride_x=2,
1259                                          stride_y=1,
1260                                          pad=False,
1261                                          out_activation_min=-111,
1262                                          out_activation_max=127,
1263                                          interpreter=interpreter,
1264                                          int4_weights=True,
1265                                          generate_bias=False)
1266    dataset = 'conv_1_x_n_3_int4'
1267    testdata_sets[dataset] = ConvSettings(dataset,
1268                                          type_of_test,
1269                                          regenerate_weights,
1270                                          regenerate_input,
1271                                          regenerate_biases,
1272                                          schema_file,
1273                                          in_ch=4,
1274                                          out_ch=1,
1275                                          x_in=296,
1276                                          y_in=1,
1277                                          w_x=48,
1278                                          w_y=1,
1279                                          stride_x=2,
1280                                          stride_y=1,
1281                                          pad=True,
1282                                          out_activation_min=-111,
1283                                          out_activation_max=127,
1284                                          interpreter=interpreter,
1285                                          int4_weights=True)
1286    dataset = 'conv_1_x_n_4_int4'  # 0 left pad, 1 right pad
1287    testdata_sets[dataset] = ConvSettings(dataset,
1288                                          type_of_test,
1289                                          regenerate_weights,
1290                                          regenerate_input,
1291                                          regenerate_biases,
1292                                          schema_file,
1293                                          in_ch=4,
1294                                          out_ch=4,
1295                                          x_in=16,
1296                                          y_in=1,
1297                                          w_x=3,
1298                                          w_y=1,
1299                                          stride_x=2,
1300                                          stride_y=1,
1301                                          pad=True,
1302                                          out_activation_min=-88,
1303                                          out_activation_max=127,
1304                                          interpreter=interpreter,
1305                                          int4_weights=True)
1306    dataset = 'conv_1_x_n_5_int4'
1307    testdata_sets[dataset] = ConvSettings(dataset,
1308                                          type_of_test,
1309                                          regenerate_weights,
1310                                          regenerate_input,
1311                                          regenerate_biases,
1312                                          schema_file,
1313                                          in_ch=4,
1314                                          out_ch=1,
1315                                          x_in=17,
1316                                          y_in=1,
1317                                          w_x=3,
1318                                          w_y=1,
1319                                          stride_x=3,
1320                                          stride_y=1,
1321                                          pad=True,
1322                                          out_activation_min=-88,
1323                                          out_activation_max=127,
1324                                          interpreter=interpreter,
1325                                          int4_weights=True)
1326
1327    dataset = 'conv_2_int4'
1328    testdata_sets[dataset] = ConvSettings(dataset,
1329                                          type_of_test,
1330                                          regenerate_weights,
1331                                          regenerate_input,
1332                                          regenerate_biases,
1333                                          schema_file,
1334                                          in_ch=2,
1335                                          out_ch=4,
1336                                          x_in=6,
1337                                          y_in=3,
1338                                          w_x=3,
1339                                          w_y=3,
1340                                          stride_x=1,
1341                                          stride_y=1,
1342                                          pad=True,
1343                                          out_activation_min=-101,
1344                                          out_activation_max=127,
1345                                          interpreter=interpreter,
1346                                          int4_weights=True)
1347    dataset = 'conv_4_int4'  # batches > 2
1348    testdata_sets[dataset] = ConvSettings(dataset,
1349                                          type_of_test,
1350                                          regenerate_weights,
1351                                          regenerate_input,
1352                                          regenerate_biases,
1353                                          schema_file,
1354                                          in_ch=3,
1355                                          out_ch=3,
1356                                          x_in=5,
1357                                          y_in=5,
1358                                          w_x=2,
1359                                          w_y=3,
1360                                          stride_x=2,
1361                                          stride_y=2,
1362                                          pad=False,
1363                                          out_activation_min=-109,
1364                                          out_activation_max=127,
1365                                          batches=3,
1366                                          interpreter=interpreter,
1367                                          int4_weights=True)
1368    dataset = 'conv_5_int4'
1369    testdata_sets[dataset] = ConvSettings(dataset,
1370                                          type_of_test,
1371                                          regenerate_weights,
1372                                          regenerate_input,
1373                                          regenerate_biases,
1374                                          schema_file,
1375                                          in_ch=128,
1376                                          out_ch=1,
1377                                          x_in=128,
1378                                          y_in=1,
1379                                          w_x=3,
1380                                          w_y=3,
1381                                          stride_x=4,
1382                                          stride_y=4,
1383                                          pad=True,
1384                                          out_activation_min=-88,
1385                                          out_activation_max=127,
1386                                          interpreter=interpreter,
1387                                          int4_weights=True,
1388                                          generate_bias=False)
1389    dataset = 'conv_out_activation_int4'
1390    testdata_sets[dataset] = ConvSettings(dataset,
1391                                          type_of_test,
1392                                          regenerate_weights,
1393                                          regenerate_input,
1394                                          regenerate_biases,
1395                                          schema_file,
1396                                          in_ch=4,
1397                                          out_ch=2,
1398                                          x_in=3,
1399                                          y_in=3,
1400                                          w_x=3,
1401                                          w_y=3,
1402                                          stride_x=1,
1403                                          stride_y=1,
1404                                          pad=True,
1405                                          out_activation_min=-61,
1406                                          out_activation_max=107,
1407                                          interpreter=interpreter,
1408                                          int4_weights=True)
1409    dataset = 'conv_dilation_golden_int4'
1410    testdata_sets[dataset] = ConvSettings(dataset,
1411                                          type_of_test,
1412                                          regenerate_weights,
1413                                          regenerate_input,
1414                                          regenerate_biases,
1415                                          schema_file,
1416                                          in_ch=1,
1417                                          batches=2,
1418                                          out_ch=3,
1419                                          x_in=6,
1420                                          y_in=4,
1421                                          w_x=2,
1422                                          w_y=2,
1423                                          stride_x=1,
1424                                          stride_y=1,
1425                                          pad=True,
1426                                          out_activation_min=-128,
1427                                          out_activation_max=127,
1428                                          dilation_x=3,
1429                                          dilation_y=2,
1430                                          interpreter=interpreter,
1431                                          int4_weights=True)
1432    dataset = 'conv_2x2_dilation_int4'
1433    testdata_sets[dataset] = ConvSettings(dataset,
1434                                          type_of_test,
1435                                          regenerate_weights,
1436                                          regenerate_input,
1437                                          regenerate_biases,
1438                                          schema_file,
1439                                          in_ch=2,
1440                                          out_ch=2,
1441                                          x_in=10,
1442                                          y_in=10,
1443                                          w_x=3,
1444                                          w_y=3,
1445                                          stride_x=1,
1446                                          stride_y=1,
1447                                          pad=False,
1448                                          out_activation_min=-61,
1449                                          out_activation_max=107,
1450                                          dilation_x=2,
1451                                          dilation_y=2,
1452                                          interpreter=interpreter,
1453                                          int4_weights=True)
1454    dataset = 'conv_2x3_dilation_int4'
1455    testdata_sets[dataset] = ConvSettings(dataset,
1456                                          type_of_test,
1457                                          regenerate_weights,
1458                                          regenerate_input,
1459                                          regenerate_biases,
1460                                          schema_file,
1461                                          in_ch=2,
1462                                          out_ch=2,
1463                                          x_in=3,
1464                                          y_in=3,
1465                                          w_x=3,
1466                                          w_y=3,
1467                                          stride_x=1,
1468                                          stride_y=1,
1469                                          pad=True,
1470                                          out_activation_min=-61,
1471                                          out_activation_max=107,
1472                                          dilation_x=2,
1473                                          dilation_y=2,
1474                                          interpreter=interpreter,
1475                                          int4_weights=True)
1476    dataset = 'conv_3x2_dilation_int4'
1477    testdata_sets[dataset] = ConvSettings(dataset,
1478                                          type_of_test,
1479                                          regenerate_weights,
1480                                          regenerate_input,
1481                                          regenerate_biases,
1482                                          schema_file,
1483                                          in_ch=2,
1484                                          out_ch=2,
1485                                          x_in=3,
1486                                          y_in=3,
1487                                          w_x=3,
1488                                          w_y=3,
1489                                          stride_x=1,
1490                                          stride_y=1,
1491                                          pad=True,
1492                                          out_activation_min=-61,
1493                                          out_activation_max=107,
1494                                          dilation_x=3,
1495                                          dilation_y=2,
1496                                          interpreter=interpreter,
1497                                          int4_weights=True)
1498    dataset = 'conv_2x2_dilation_5x5_input_int4'
1499    testdata_sets[dataset] = ConvSettings(dataset,
1500                                          type_of_test,
1501                                          regenerate_weights,
1502                                          regenerate_input,
1503                                          regenerate_biases,
1504                                          schema_file,
1505                                          in_ch=2,
1506                                          out_ch=2,
1507                                          x_in=5,
1508                                          y_in=5,
1509                                          w_x=3,
1510                                          w_y=3,
1511                                          stride_x=1,
1512                                          stride_y=1,
1513                                          pad=True,
1514                                          out_activation_min=-61,
1515                                          out_activation_max=107,
1516                                          dilation_x=2,
1517                                          dilation_y=2,
1518                                          interpreter=interpreter,
1519                                          int4_weights=True)
1520    dataset = 'conv_3x3_dilation_5x5_input_int4'
1521    testdata_sets[dataset] = ConvSettings(dataset,
1522                                          type_of_test,
1523                                          regenerate_weights,
1524                                          regenerate_input,
1525                                          regenerate_biases,
1526                                          schema_file,
1527                                          in_ch=2,
1528                                          out_ch=2,
1529                                          x_in=9,
1530                                          y_in=11,
1531                                          w_x=3,
1532                                          w_y=3,
1533                                          stride_x=1,
1534                                          stride_y=1,
1535                                          pad=True,
1536                                          out_activation_min=-61,
1537                                          out_activation_max=107,
1538                                          dilation_x=2,
1539                                          dilation_y=2,
1540                                          interpreter=interpreter,
1541                                          int4_weights=True)
1542
1543    type_of_test = 'transpose_conv'
1544    dataset = 'transpose_conv_1'
1545    testdata_sets[dataset] = ConvSettings(dataset,
1546                                          type_of_test,
1547                                          regenerate_weights,
1548                                          regenerate_input,
1549                                          regenerate_biases,
1550                                          schema_file,
1551                                          in_ch=32,
1552                                          batches=2,
1553                                          out_ch=3,
1554                                          x_in=9,
1555                                          y_in=9,
1556                                          w_x=6,
1557                                          w_y=6,
1558                                          generate_bias=True,
1559                                          stride_x=2,
1560                                          stride_y=2,
1561                                          pad=True,
1562                                          interpreter=interpreter)
1563    dataset = 'transpose_conv_2'
1564    testdata_sets[dataset] = ConvSettings(dataset,
1565                                          type_of_test,
1566                                          regenerate_weights,
1567                                          regenerate_input,
1568                                          regenerate_biases,
1569                                          schema_file,
1570                                          in_ch=15,
1571                                          batches=1,
1572                                          out_ch=4,
1573                                          x_in=12,
1574                                          y_in=12,
1575                                          w_x=3,
1576                                          w_y=3,
1577                                          generate_bias=False,
1578                                          stride_x=3,
1579                                          stride_y=1,
1580                                          pad=False,
1581                                          interpreter=interpreter)
1582    dataset = 'transpose_conv_3'
1583    testdata_sets[dataset] = ConvSettings(dataset,
1584                                          type_of_test,
1585                                          regenerate_weights,
1586                                          regenerate_input,
1587                                          regenerate_biases,
1588                                          schema_file,
1589                                          in_ch=7,
1590                                          batches=3,
1591                                          out_ch=5,
1592                                          x_in=1,
1593                                          y_in=7,
1594                                          w_x=5,
1595                                          w_y=1,
1596                                          generate_bias=True,
1597                                          stride_x=2,
1598                                          stride_y=5,
1599                                          pad=True,
1600                                          interpreter=interpreter)
1601    dataset = 'transpose_conv_4'
1602    testdata_sets[dataset] = ConvSettings(dataset,
1603                                          type_of_test,
1604                                          regenerate_weights,
1605                                          regenerate_input,
1606                                          regenerate_biases,
1607                                          schema_file,
1608                                          in_ch=32,
1609                                          batches=3,
1610                                          out_ch=5,
1611                                          x_in=1,
1612                                          y_in=7,
1613                                          w_x=3,
1614                                          w_y=3,
1615                                          generate_bias=False,
1616                                          stride_x=3,
1617                                          stride_y=1,
1618                                          pad=False,
1619                                          interpreter=interpreter)
1620
1621    type_of_test = 'depthwise_conv'
1622    dataset = 'depthwise_2'
1623    testdata_sets[dataset] = ConvSettings(dataset,
1624                                          type_of_test,
1625                                          regenerate_weights,
1626                                          regenerate_input,
1627                                          regenerate_biases,
1628                                          schema_file,
1629                                          in_ch=3,
1630                                          out_ch=9,
1631                                          x_in=6,
1632                                          y_in=5,
1633                                          w_x=3,
1634                                          w_y=4,
1635                                          stride_x=2,
1636                                          stride_y=2,
1637                                          pad=True,
1638                                          out_activation_min=-73,
1639                                          out_activation_max=127,
1640                                          interpreter=interpreter)
1641    dataset = 'depthwise_kernel_3x3'
1642    testdata_sets[dataset] = ConvSettings(dataset,
1643                                          type_of_test,
1644                                          regenerate_weights,
1645                                          regenerate_input,
1646                                          regenerate_biases,
1647                                          schema_file,
1648                                          in_ch=5,
1649                                          out_ch=5,
1650                                          x_in=4,
1651                                          y_in=5,
1652                                          w_x=3,
1653                                          w_y=3,
1654                                          stride_x=2,
1655                                          stride_y=2,
1656                                          pad=True,
1657                                          bias_min=TestSettings.INT8_MIN,
1658                                          bias_max=TestSettings.INT8_MAX,
1659                                          out_activation_min=-104,
1660                                          out_activation_max=127,
1661                                          interpreter=interpreter)
1662    dataset = 'depthwise_kernel_3x3_null_bias'
1663    testdata_sets[dataset] = ConvSettings(dataset,
1664                                          type_of_test,
1665                                          regenerate_weights,
1666                                          regenerate_input,
1667                                          regenerate_biases,
1668                                          schema_file,
1669                                          in_ch=5,
1670                                          out_ch=5,
1671                                          x_in=4,
1672                                          y_in=5,
1673                                          w_x=3,
1674                                          w_y=3,
1675                                          stride_x=2,
1676                                          stride_y=2,
1677                                          pad=True,
1678                                          generate_bias=False,
1679                                          out_activation_min=-104,
1680                                          out_activation_max=127,
1681                                          interpreter=interpreter)
1682    dataset = 'depthwise_eq_in_out_ch'
1683    testdata_sets[dataset] = ConvSettings(dataset,
1684                                          type_of_test,
1685                                          regenerate_weights,
1686                                          regenerate_input,
1687                                          regenerate_biases,
1688                                          schema_file,
1689                                          in_ch=250,
1690                                          out_ch=250,
1691                                          x_in=7,
1692                                          y_in=5,
1693                                          w_x=2,
1694                                          w_y=2,
1695                                          stride_x=1,
1696                                          stride_y=1,
1697                                          pad=True,
1698                                          interpreter=interpreter)
1699    dataset = 'depthwise_sub_block'
1700    testdata_sets[dataset] = ConvSettings(dataset,
1701                                          type_of_test,
1702                                          regenerate_weights,
1703                                          regenerate_input,
1704                                          regenerate_biases,
1705                                          schema_file,
1706                                          in_ch=9,
1707                                          out_ch=9,
1708                                          x_in=7,
1709                                          y_in=5,
1710                                          w_x=2,
1711                                          w_y=2,
1712                                          stride_x=1,
1713                                          stride_y=1,
1714                                          pad=False,
1715                                          interpreter=interpreter)
1716    dataset = 'depthwise_x_stride'
1717    testdata_sets[dataset] = ConvSettings(dataset,
1718                                          type_of_test,
1719                                          regenerate_weights,
1720                                          regenerate_input,
1721                                          regenerate_biases,
1722                                          schema_file,
1723                                          in_ch=9,
1724                                          out_ch=9,
1725                                          x_in=7,
1726                                          y_in=5,
1727                                          w_x=2,
1728                                          w_y=2,
1729                                          stride_x=2,
1730                                          stride_y=1,
1731                                          pad=False,
1732                                          interpreter=interpreter)
1733    dataset = 'depthwise_out_activation'
1734    testdata_sets[dataset] = ConvSettings(dataset,
1735                                          type_of_test,
1736                                          regenerate_weights,
1737                                          regenerate_input,
1738                                          regenerate_biases,
1739                                          schema_file,
1740                                          in_ch=3,
1741                                          out_ch=3,
1742                                          x_in=6,
1743                                          y_in=5,
1744                                          w_x=3,
1745                                          w_y=4,
1746                                          pad=False,
1747                                          out_activation_min=-45,
1748                                          out_activation_max=103,
1749                                          interpreter=interpreter)
1750    dataset = 'depthwise_mult_batches'
1751    testdata_sets[dataset] = ConvSettings(dataset,
1752                                          type_of_test,
1753                                          regenerate_weights,
1754                                          regenerate_input,
1755                                          regenerate_biases,
1756                                          schema_file,
1757                                          in_ch=3,
1758                                          out_ch=3,
1759                                          x_in=3,
1760                                          y_in=5,
1761                                          w_x=2,
1762                                          w_y=4,
1763                                          stride_x=2,
1764                                          stride_y=2,
1765                                          pad=True,
1766                                          batches=2,
1767                                          interpreter=interpreter)
1768    dataset = 'depthwise_null_bias_0'
1769    testdata_sets[dataset] = ConvSettings(dataset,
1770                                          type_of_test,
1771                                          regenerate_weights,
1772                                          regenerate_input,
1773                                          regenerate_biases,
1774                                          schema_file,
1775                                          in_ch=2,
1776                                          out_ch=2,
1777                                          x_in=4,
1778                                          y_in=5,
1779                                          w_x=2,
1780                                          w_y=2,
1781                                          stride_x=1,
1782                                          stride_y=1,
1783                                          pad=True,
1784                                          generate_bias=False,
1785                                          batches=1,
1786                                          interpreter=interpreter)
1787    dataset = 'depthwise_null_bias_1'
1788    testdata_sets[dataset] = ConvSettings(dataset,
1789                                          type_of_test,
1790                                          regenerate_weights,
1791                                          regenerate_input,
1792                                          regenerate_biases,
1793                                          schema_file,
1794                                          in_ch=2,
1795                                          out_ch=16,
1796                                          x_in=4,
1797                                          y_in=5,
1798                                          w_x=2,
1799                                          w_y=2,
1800                                          stride_x=1,
1801                                          stride_y=1,
1802                                          pad=True,
1803                                          generate_bias=False,
1804                                          batches=1,
1805                                          interpreter=interpreter)
1806    dataset = 'depthwise_dilation'
1807    testdata_sets[dataset] = ConvSettings(dataset,
1808                                          type_of_test,
1809                                          regenerate_weights,
1810                                          regenerate_input,
1811                                          regenerate_biases,
1812                                          schema_file,
1813                                          in_ch=3,
1814                                          out_ch=9,
1815                                          x_in=6,
1816                                          y_in=5,
1817                                          w_x=3,
1818                                          w_y=4,
1819                                          stride_x=1,
1820                                          stride_y=1,
1821                                          pad=True,
1822                                          out_activation_min=-70,
1823                                          out_activation_max=127,
1824                                          dilation_x=2,
1825                                          dilation_y=3,
1826                                          interpreter=interpreter)
1827    dataset = 'dw_int16xint8'
1828    testdata_sets[dataset] = ConvSettings(dataset,
1829                                          type_of_test,
1830                                          regenerate_weights,
1831                                          regenerate_input,
1832                                          regenerate_biases,
1833                                          schema_file,
1834                                          in_ch=4,
1835                                          out_ch=8,
1836                                          x_in=9,
1837                                          y_in=5,
1838                                          w_x=3,
1839                                          w_y=4,
1840                                          stride_x=3,
1841                                          stride_y=2,
1842                                          pad=True,
1843                                          randmin=TestSettings.INT16_MIN,
1844                                          randmax=TestSettings.INT16_MAX,
1845                                          out_activation_min=-21111,
1846                                          out_activation_max=32767,
1847                                          int16xint8=True,
1848                                          interpreter=interpreter)
1849    dataset = 'dw_int16xint8_dilation'
1850    testdata_sets[dataset] = ConvSettings(dataset,
1851                                          type_of_test,
1852                                          regenerate_weights,
1853                                          regenerate_input,
1854                                          regenerate_biases,
1855                                          schema_file,
1856                                          in_ch=4,
1857                                          out_ch=8,
1858                                          x_in=9,
1859                                          y_in=5,
1860                                          w_x=4,
1861                                          w_y=4,
1862                                          stride_x=1,
1863                                          stride_y=1,
1864                                          pad=True,
1865                                          randmin=TestSettings.INT16_MIN,
1866                                          randmax=TestSettings.INT16_MAX,
1867                                          out_activation_min=-32700,
1868                                          dilation_x=3,
1869                                          dilation_y=2,
1870                                          out_activation_max=32767,
1871                                          int16xint8=True,
1872                                          interpreter=interpreter)
1873    dataset = 'dw_int16xint8_mult4'
1874    testdata_sets[dataset] = ConvSettings(dataset,
1875                                          type_of_test,
1876                                          regenerate_weights,
1877                                          regenerate_input,
1878                                          regenerate_biases,
1879                                          schema_file,
1880                                          in_ch=2,
1881                                          out_ch=8,
1882                                          x_in=4,
1883                                          y_in=5,
1884                                          w_x=3,
1885                                          w_y=4,
1886                                          stride_x=3,
1887                                          stride_y=2,
1888                                          pad=False,
1889                                          randmin=TestSettings.INT16_MIN,
1890                                          randmax=TestSettings.INT16_MAX,
1891                                          out_activation_min=-32767,
1892                                          out_activation_max=32767,
1893                                          int16xint8=True,
1894                                          interpreter=interpreter)
1895    dataset = 'dw_int16xint8_fast'
1896    testdata_sets[dataset] = ConvSettings(dataset,
1897                                          type_of_test,
1898                                          regenerate_weights,
1899                                          regenerate_input,
1900                                          regenerate_biases,
1901                                          schema_file,
1902                                          in_ch=8,
1903                                          out_ch=8,
1904                                          x_in=4,
1905                                          y_in=4,
1906                                          w_x=2,
1907                                          w_y=2,
1908                                          stride_x=1,
1909                                          stride_y=1,
1910                                          pad=False,
1911                                          randmin=TestSettings.INT16_MIN,
1912                                          randmax=TestSettings.INT16_MAX,
1913                                          out_activation_min=-17000,
1914                                          out_activation_max=32767,
1915                                          int16xint8=True,
1916                                          interpreter=interpreter)
1917    dataset = 'dw_int16xint8_fast_multiple_batches_uneven_buffers'
1918    testdata_sets[dataset] = ConvSettings(dataset,
1919                                          type_of_test,
1920                                          regenerate_weights,
1921                                          regenerate_input,
1922                                          regenerate_biases,
1923                                          schema_file,
1924                                          in_ch=8,
1925                                          out_ch=8,
1926                                          x_in=5,
1927                                          y_in=5,
1928                                          w_x=3,
1929                                          w_y=3,
1930                                          stride_x=1,
1931                                          stride_y=1,
1932                                          pad=False,
1933                                          randmin=TestSettings.INT16_MIN,
1934                                          randmax=TestSettings.INT16_MAX,
1935                                          out_activation_min=-17000,
1936                                          out_activation_max=32767,
1937                                          int16xint8=True,
1938                                          batches=3,
1939                                          interpreter=interpreter)
1940    dataset = 'dw_int16xint8_fast_multiple_batches_uneven_buffers_null_bias'
1941    testdata_sets[dataset] = ConvSettings(dataset,
1942                                          type_of_test,
1943                                          regenerate_weights,
1944                                          regenerate_input,
1945                                          regenerate_biases,
1946                                          schema_file,
1947                                          in_ch=8,
1948                                          out_ch=8,
1949                                          x_in=4,
1950                                          y_in=4,
1951                                          w_x=3,
1952                                          w_y=2,
1953                                          stride_x=1,
1954                                          stride_y=1,
1955                                          pad=False,
1956                                          randmin=TestSettings.INT16_MIN,
1957                                          randmax=TestSettings.INT16_MAX,
1958                                          out_activation_min=-17000,
1959                                          out_activation_max=32767,
1960                                          int16xint8=True,
1961                                          batches=3,
1962                                          generate_bias=False,
1963                                          interpreter=interpreter)
1964
1965    dataset = 'dw_int16xint8_fast_test_bias'
1966    nbr_of_out_channels = 8
1967    bias = [i for i in range(nbr_of_out_channels)]
1968    testdata_sets[dataset] = ConvSettings(dataset,
1969                                          type_of_test,
1970                                          regenerate_weights,
1971                                          regenerate_input,
1972                                          regenerate_biases,
1973                                          schema_file,
1974                                          in_ch=8,
1975                                          out_ch=nbr_of_out_channels,
1976                                          x_in=4,
1977                                          y_in=4,
1978                                          w_x=2,
1979                                          w_y=2,
1980                                          stride_x=1,
1981                                          stride_y=1,
1982                                          pad=False,
1983                                          randmin=TestSettings.INT16_MIN,
1984                                          randmax=TestSettings.INT16_MAX,
1985                                          out_activation_min=-17000,
1986                                          out_activation_max=32767,
1987                                          int16xint8=True,
1988                                          generate_bias=bias,
1989                                          interpreter=interpreter)
1990
1991    dataset = 'dw_int16xint8_fast_null_bias'
1992    testdata_sets[dataset] = ConvSettings(dataset,
1993                                          type_of_test,
1994                                          regenerate_weights,
1995                                          regenerate_input,
1996                                          regenerate_biases,
1997                                          schema_file,
1998                                          in_ch=8,
1999                                          out_ch=8,
2000                                          x_in=4,
2001                                          y_in=4,
2002                                          w_x=2,
2003                                          w_y=2,
2004                                          stride_x=1,
2005                                          stride_y=1,
2006                                          pad=False,
2007                                          randmin=TestSettings.INT16_MIN,
2008                                          randmax=TestSettings.INT16_MAX,
2009                                          out_activation_min=-17000,
2010                                          out_activation_max=32767,
2011                                          int16xint8=True,
2012                                          generate_bias=False,
2013                                          interpreter=interpreter)
2014    dataset = 'dw_int16xint8_fast_stride'
2015    testdata_sets[dataset] = ConvSettings(dataset,
2016                                          type_of_test,
2017                                          regenerate_weights,
2018                                          regenerate_input,
2019                                          regenerate_biases,
2020                                          schema_file,
2021                                          in_ch=8,
2022                                          out_ch=8,
2023                                          x_in=4,
2024                                          y_in=4,
2025                                          w_x=2,
2026                                          w_y=2,
2027                                          stride_x=2,
2028                                          stride_y=2,
2029                                          pad=True,
2030                                          randmin=TestSettings.INT16_MIN,
2031                                          randmax=TestSettings.INT16_MAX,
2032                                          batches=2,
2033                                          out_activation_min=TestSettings.INT16_MIN,
2034                                          out_activation_max=16000,
2035                                          int16xint8=True,
2036                                          interpreter=interpreter)
2037    dataset = 'dw_int16xint8_fast_stride_null_bias'
2038    testdata_sets[dataset] = ConvSettings(dataset,
2039                                          type_of_test,
2040                                          regenerate_weights,
2041                                          regenerate_input,
2042                                          regenerate_biases,
2043                                          schema_file,
2044                                          in_ch=8,
2045                                          out_ch=8,
2046                                          x_in=4,
2047                                          y_in=4,
2048                                          w_x=2,
2049                                          w_y=2,
2050                                          stride_x=2,
2051                                          stride_y=2,
2052                                          pad=True,
2053                                          randmin=TestSettings.INT16_MIN,
2054                                          randmax=TestSettings.INT16_MAX,
2055                                          batches=2,
2056                                          out_activation_min=TestSettings.INT16_MIN,
2057                                          out_activation_max=16000,
2058                                          int16xint8=True,
2059                                          generate_bias=False,
2060                                          interpreter=interpreter)
2061    dataset = 'dw_int16xint8_fast_spill'
2062    testdata_sets[dataset] = ConvSettings(dataset,
2063                                          type_of_test,
2064                                          regenerate_weights,
2065                                          regenerate_input,
2066                                          regenerate_biases,
2067                                          schema_file,
2068                                          in_ch=5,
2069                                          out_ch=5,
2070                                          x_in=4,
2071                                          y_in=4,
2072                                          w_x=3,
2073                                          w_y=3,
2074                                          stride_x=2,
2075                                          stride_y=1,
2076                                          pad=True,
2077                                          randmin=TestSettings.INT16_MIN,
2078                                          randmax=TestSettings.INT16_MAX,
2079                                          batches=3,
2080                                          out_activation_min=-30000,
2081                                          out_activation_max=32767,
2082                                          int16xint8=True,
2083                                          interpreter=interpreter)
2084    dataset = 'dw_int16xint8_fast_spill_null_bias'
2085    testdata_sets[dataset] = ConvSettings(dataset,
2086                                          type_of_test,
2087                                          regenerate_weights,
2088                                          regenerate_input,
2089                                          regenerate_biases,
2090                                          schema_file,
2091                                          in_ch=5,
2092                                          out_ch=5,
2093                                          x_in=4,
2094                                          y_in=4,
2095                                          w_x=3,
2096                                          w_y=3,
2097                                          stride_x=2,
2098                                          stride_y=1,
2099                                          pad=True,
2100                                          randmin=TestSettings.INT16_MIN,
2101                                          randmax=TestSettings.INT16_MAX,
2102                                          batches=3,
2103                                          out_activation_min=-30000,
2104                                          out_activation_max=32767,
2105                                          int16xint8=True,
2106                                          generate_bias=False,
2107                                          interpreter=interpreter)
2108    dataset = 'depthwise_int4_1'
2109    testdata_sets[dataset] = ConvSettings(dataset,
2110                                          type_of_test,
2111                                          regenerate_weights,
2112                                          regenerate_input,
2113                                          regenerate_biases,
2114                                          schema_file,
2115                                          in_ch=22,
2116                                          out_ch=22,
2117                                          x_in=1,
2118                                          y_in=23,
2119                                          w_x=1,
2120                                          w_y=3,
2121                                          stride_x=1,
2122                                          stride_y=1,
2123                                          pad=False,
2124                                          out_activation_min=-127,
2125                                          out_activation_max=127,
2126                                          generate_bias=False,
2127                                          interpreter=interpreter,
2128                                          int4_weights=True)
2129    dataset = 'depthwise_int4_2'
2130    testdata_sets[dataset] = ConvSettings(dataset,
2131                                          type_of_test,
2132                                          regenerate_weights,
2133                                          regenerate_input,
2134                                          regenerate_biases,
2135                                          schema_file,
2136                                          in_ch=19,
2137                                          out_ch=19,
2138                                          x_in=6,
2139                                          y_in=6,
2140                                          w_x=5,
2141                                          w_y=5,
2142                                          stride_x=1,
2143                                          stride_y=1,
2144                                          pad=False,
2145                                          out_activation_min=-127,
2146                                          out_activation_max=127,
2147                                          generate_bias=False,
2148                                          interpreter=interpreter,
2149                                          int4_weights=True)
2150    dataset = 'depthwise_int4_3'
2151    testdata_sets[dataset] = ConvSettings(dataset,
2152                                          type_of_test,
2153                                          regenerate_weights,
2154                                          regenerate_input,
2155                                          regenerate_biases,
2156                                          schema_file,
2157                                          in_ch=1,
2158                                          out_ch=1,
2159                                          x_in=2,
2160                                          y_in=2,
2161                                          w_x=2,
2162                                          w_y=2,
2163                                          stride_x=1,
2164                                          stride_y=1,
2165                                          pad=False,
2166                                          out_activation_min=-127,
2167                                          out_activation_max=127,
2168                                          generate_bias=False,
2169                                          interpreter=interpreter,
2170                                          int4_weights=True)
2171    dataset = 'depthwise_int4_4'
2172    testdata_sets[dataset] = ConvSettings(dataset,
2173                                          type_of_test,
2174                                          regenerate_weights,
2175                                          regenerate_input,
2176                                          regenerate_biases,
2177                                          schema_file,
2178                                          in_ch=3,
2179                                          out_ch=3,
2180                                          x_in=4,
2181                                          y_in=4,
2182                                          w_x=2,
2183                                          w_y=2,
2184                                          stride_x=2,
2185                                          stride_y=2,
2186                                          pad=False,
2187                                          out_activation_min=-127,
2188                                          out_activation_max=127,
2189                                          generate_bias=False,
2190                                          interpreter=interpreter,
2191                                          int4_weights=True)
2192    dataset = 'depthwise_int4_generic'
2193    testdata_sets[dataset] = ConvSettings(dataset,
2194                                          type_of_test,
2195                                          regenerate_weights,
2196                                          regenerate_input,
2197                                          regenerate_biases,
2198                                          schema_file,
2199                                          in_ch=2,
2200                                          out_ch=8,
2201                                          x_in=16,
2202                                          y_in=16,
2203                                          w_x=8,
2204                                          w_y=8,
2205                                          stride_x=2,
2206                                          stride_y=2,
2207                                          pad=False,
2208                                          out_activation_min=-127,
2209                                          out_activation_max=127,
2210                                          generate_bias=False,
2211                                          interpreter=interpreter,
2212                                          int4_weights=True)
2213    dataset = 'depthwise_int4_generic_2'
2214    testdata_sets[dataset] = ConvSettings(dataset,
2215                                          type_of_test,
2216                                          regenerate_weights,
2217                                          regenerate_input,
2218                                          regenerate_biases,
2219                                          schema_file,
2220                                          in_ch=3,
2221                                          out_ch=9,
2222                                          x_in=9,
2223                                          y_in=9,
2224                                          w_x=6,
2225                                          w_y=5,
2226                                          stride_x=2,
2227                                          stride_y=1,
2228                                          pad=True,
2229                                          out_activation_min=-127,
2230                                          out_activation_max=127,
2231                                          generate_bias=True,
2232                                          interpreter=interpreter,
2233                                          int4_weights=True)
2234    dataset = 'depthwise_int4_generic_3'
2235    testdata_sets[dataset] = ConvSettings(dataset,
2236                                          type_of_test,
2237                                          regenerate_weights,
2238                                          regenerate_input,
2239                                          regenerate_biases,
2240                                          schema_file,
2241                                          in_ch=4,
2242                                          out_ch=8,
2243                                          x_in=9,
2244                                          y_in=9,
2245                                          w_x=5,
2246                                          w_y=5,
2247                                          stride_x=1,
2248                                          stride_y=1,
2249                                          pad=False,
2250                                          out_activation_min=-127,
2251                                          out_activation_max=125,
2252                                          dilation_x=2,
2253                                          dilation_y=2,
2254                                          generate_bias=True,
2255                                          interpreter=interpreter,
2256                                          int4_weights=True)
2257    dataset = 'depthwise_int4_generic_4'
2258    testdata_sets[dataset] = ConvSettings(dataset,
2259                                          type_of_test,
2260                                          regenerate_weights,
2261                                          regenerate_input,
2262                                          regenerate_biases,
2263                                          schema_file,
2264                                          in_ch=1,
2265                                          out_ch=3,
2266                                          x_in=12,
2267                                          y_in=10,
2268                                          w_x=5,
2269                                          w_y=5,
2270                                          stride_x=1,
2271                                          stride_y=2,
2272                                          pad=True,
2273                                          out_activation_min=-127,
2274                                          out_activation_max=127,
2275                                          generate_bias=True,
2276                                          interpreter=interpreter,
2277                                          int4_weights=True)
2278    dataset = 'depthwise_int4_generic_5'
2279    testdata_sets[dataset] = ConvSettings(dataset,
2280                                          type_of_test,
2281                                          regenerate_weights,
2282                                          regenerate_input,
2283                                          regenerate_biases,
2284                                          schema_file,
2285                                          in_ch=20,
2286                                          out_ch=20,
2287                                          x_in=21,
2288                                          y_in=21,
2289                                          w_x=5,
2290                                          w_y=5,
2291                                          stride_x=1,
2292                                          stride_y=2,
2293                                          pad=False,
2294                                          out_activation_min=-127,
2295                                          out_activation_max=125,
2296                                          dilation_x=2,
2297                                          dilation_y=2,
2298                                          generate_bias=True,
2299                                          interpreter=interpreter,
2300                                          int4_weights=True)
2301    dataset = 'depthwise_int4_generic_6'
2302    testdata_sets[dataset] = ConvSettings(dataset,
2303                                          type_of_test,
2304                                          regenerate_weights,
2305                                          regenerate_input,
2306                                          regenerate_biases,
2307                                          schema_file,
2308                                          in_ch=4,
2309                                          out_ch=12,
2310                                          x_in=21,
2311                                          y_in=21,
2312                                          w_x=3,
2313                                          w_y=3,
2314                                          stride_x=1,
2315                                          stride_y=1,
2316                                          pad=False,
2317                                          out_activation_min=-127,
2318                                          out_activation_max=125,
2319                                          dilation_x=1,
2320                                          dilation_y=2,
2321                                          generate_bias=True,
2322                                          interpreter=interpreter,
2323                                          int4_weights=True)
2324
2325    type_of_test = 'fully_connected'
2326    dataset = 'fully_connected'
2327    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2328                                                    type_of_test,
2329                                                    regenerate_weights,
2330                                                    regenerate_input,
2331                                                    regenerate_biases,
2332                                                    schema_file,
2333                                                    in_ch=10,
2334                                                    out_ch=6,
2335                                                    x_in=2,
2336                                                    y_in=1,
2337                                                    batches=3,
2338                                                    interpreter=interpreter)
2339    dataset = 'fully_connected_w_zp'
2340    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2341                                                    type_of_test,
2342                                                    regenerate_weights,
2343                                                    regenerate_input,
2344                                                    regenerate_biases,
2345                                                    schema_file,
2346                                                    in_ch=10,
2347                                                    out_ch=6,
2348                                                    x_in=2,
2349                                                    y_in=1,
2350                                                    batches=3,
2351                                                    input_scale=0.034,
2352                                                    w_scale=0.054,
2353                                                    bias_scale=0.00000001,
2354                                                    output_scale=0.356,
2355                                                    input_zp=2,
2356                                                    output_zp=35,
2357                                                    w_zp=15,
2358                                                    generate_bias=False,
2359                                                    interpreter=interpreter)
2360    dataset = 'fully_connected_mve_0'
2361    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2362                                                    type_of_test,
2363                                                    regenerate_weights,
2364                                                    regenerate_input,
2365                                                    regenerate_biases,
2366                                                    schema_file,
2367                                                    in_ch=16,
2368                                                    out_ch=9,
2369                                                    x_in=1,
2370                                                    y_in=1,
2371                                                    batches=1,
2372                                                    interpreter=interpreter)
2373    dataset = 'fully_connected_mve_1'
2374    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2375                                                    type_of_test,
2376                                                    regenerate_weights,
2377                                                    regenerate_input,
2378                                                    regenerate_biases,
2379                                                    schema_file,
2380                                                    in_ch=20,
2381                                                    out_ch=4,
2382                                                    x_in=1,
2383                                                    y_in=1,
2384                                                    batches=1,
2385                                                    interpreter=interpreter)
2386    dataset = 'fully_connected_null_bias_0'
2387    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2388                                                    type_of_test,
2389                                                    regenerate_weights,
2390                                                    regenerate_input,
2391                                                    regenerate_biases,
2392                                                    schema_file,
2393                                                    in_ch=33,
2394                                                    out_ch=5,
2395                                                    batches=2,
2396                                                    generate_bias=False,
2397                                                    interpreter=interpreter)
2398    dataset = 'fully_connected_out_activation'
2399    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2400                                                    type_of_test,
2401                                                    regenerate_weights,
2402                                                    regenerate_input,
2403                                                    regenerate_biases,
2404                                                    schema_file,
2405                                                    in_ch=10,
2406                                                    out_ch=4,
2407                                                    out_activation_min=-70,
2408                                                    out_activation_max=100,
2409                                                    interpreter=interpreter)
2410    dataset = 'fully_connected_int16'
2411    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2412                                                    type_of_test,
2413                                                    regenerate_weights,
2414                                                    regenerate_input,
2415                                                    regenerate_biases,
2416                                                    schema_file,
2417                                                    in_ch=7,
2418                                                    out_ch=11,
2419                                                    x_in=3,
2420                                                    y_in=3,
2421                                                    batches=2,
2422                                                    randmin=TestSettings.INT16_MIN,
2423                                                    randmax=TestSettings.INT16_MAX,
2424                                                    out_activation_min=-9999,
2425                                                    out_activation_max=32767,
2426                                                    int16xint8=True,
2427                                                    interpreter=interpreter)
2428    dataset = 'fully_connected_int4'
2429    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2430                                                    type_of_test,
2431                                                    regenerate_weights,
2432                                                    regenerate_input,
2433                                                    regenerate_biases,
2434                                                    schema_file,
2435                                                    int4_weights=True,
2436                                                    in_ch=82,
2437                                                    out_ch=21,
2438                                                    x_in=1,
2439                                                    y_in=1,
2440                                                    batches=1,
2441                                                    bias_min=TestSettings.INT8_MIN,
2442                                                    bias_max=TestSettings.INT8_MAX,
2443                                                    int16xint8=False,
2444                                                    input_zp=3,
2445                                                    output_zp=-3,
2446                                                    interpreter=interpreter)
2447    dataset = 'fully_connected_int4_2'
2448    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2449                                                    type_of_test,
2450                                                    regenerate_weights,
2451                                                    regenerate_input,
2452                                                    regenerate_biases,
2453                                                    schema_file,
2454                                                    int4_weights=True,
2455                                                    in_ch=84,
2456                                                    out_ch=23,
2457                                                    x_in=1,
2458                                                    y_in=1,
2459                                                    batches=1,
2460                                                    bias_min=TestSettings.INT8_MIN,
2461                                                    bias_max=TestSettings.INT8_MAX,
2462                                                    generate_bias=True,
2463                                                    int16xint8=False,
2464                                                    input_zp=-4,
2465                                                    output_zp=16,
2466                                                    interpreter=interpreter)
2467    dataset = 'fully_connected_int4_3'
2468    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2469                                                    type_of_test,
2470                                                    regenerate_weights,
2471                                                    regenerate_input,
2472                                                    regenerate_biases,
2473                                                    schema_file,
2474                                                    int4_weights=True,
2475                                                    in_ch=86,
2476                                                    out_ch=25,
2477                                                    x_in=1,
2478                                                    y_in=1,
2479                                                    batches=1,
2480                                                    bias_min=TestSettings.INT8_MIN,
2481                                                    bias_max=TestSettings.INT8_MAX,
2482                                                    out_activation_min=-64,
2483                                                    out_activation_max=64,
2484                                                    int16xint8=False,
2485                                                    input_zp=1,
2486                                                    output_zp=0,
2487                                                    interpreter=interpreter)
2488    dataset = 'fully_connected_int4_4'
2489    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2490                                                    type_of_test,
2491                                                    regenerate_weights,
2492                                                    regenerate_input,
2493                                                    regenerate_biases,
2494                                                    schema_file,
2495                                                    int4_weights=True,
2496                                                    in_ch=85,
2497                                                    out_ch=19,
2498                                                    x_in=1,
2499                                                    y_in=1,
2500                                                    batches=1,
2501                                                    bias_min=TestSettings.INT8_MIN,
2502                                                    bias_max=TestSettings.INT8_MAX,
2503                                                    generate_bias=False,
2504                                                    int16xint8=False,
2505                                                    input_zp=-2,
2506                                                    output_zp=0,
2507                                                    interpreter=interpreter)
2508    dataset = 'fully_connected_int4_5'
2509    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2510                                                    type_of_test,
2511                                                    regenerate_weights,
2512                                                    regenerate_input,
2513                                                    regenerate_biases,
2514                                                    schema_file,
2515                                                    int4_weights=True,
2516                                                    in_ch=16,
2517                                                    out_ch=20,
2518                                                    bias_min=TestSettings.INT8_MIN,
2519                                                    bias_max=TestSettings.INT8_MAX,
2520                                                    input_zp=120,
2521                                                    output_zp=100,
2522                                                    interpreter=interpreter)
2523    dataset = 'fully_connected_int4_6'
2524    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2525                                                    type_of_test,
2526                                                    regenerate_weights,
2527                                                    regenerate_input,
2528                                                    regenerate_biases,
2529                                                    schema_file,
2530                                                    int4_weights=True,
2531                                                    in_ch=89,
2532                                                    out_ch=22,
2533                                                    x_in=1,
2534                                                    bias_min=TestSettings.INT32_MIN,
2535                                                    bias_max=TestSettings.INT32_MAX,
2536                                                    y_in=1,
2537                                                    batches=1,
2538                                                    generate_bias=False,
2539                                                    int16xint8=False,
2540                                                    input_zp=-127,
2541                                                    output_zp=128,
2542                                                    interpreter=interpreter)
2543    dataset = 'fully_connected_int16_big'
2544    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2545                                                    type_of_test,
2546                                                    regenerate_weights,
2547                                                    regenerate_input,
2548                                                    regenerate_biases,
2549                                                    schema_file,
2550                                                    in_ch=7,
2551                                                    out_ch=11,
2552                                                    x_in=10,
2553                                                    y_in=10,
2554                                                    batches=3,
2555                                                    out_activation_min=-1444,
2556                                                    out_activation_max=32767,
2557                                                    int16xint8=True,
2558                                                    interpreter=interpreter)
2559    dataset = 'fc_int16_slow'
2560    testdata_sets[dataset] = FullyConnectedSettings(dataset,
2561                                                    type_of_test,
2562                                                    regenerate_weights,
2563                                                    regenerate_input,
2564                                                    regenerate_biases,
2565                                                    schema_file,
2566                                                    in_ch=7,
2567                                                    out_ch=11,
2568                                                    x_in=10,
2569                                                    y_in=8,
2570                                                    batches=3,
2571                                                    randmin=(TestSettings.INT16_MAX - 100),
2572                                                    randmax=TestSettings.INT16_MAX,
2573                                                    int16xint8=True,
2574                                                    interpreter=interpreter)
2575
2576    type_of_test = 'avgpool'
2577    dataset = 'avgpooling'
2578    testdata_sets[dataset] = PoolingSettings(dataset,
2579                                             type_of_test,
2580                                             regenerate_weights,
2581                                             regenerate_input,
2582                                             regenerate_biases,
2583                                             schema_file,
2584                                             channels=20,
2585                                             x_in=22,
2586                                             y_in=12,
2587                                             stride_x=9,
2588                                             stride_y=5,
2589                                             w_x=6,
2590                                             w_y=5,
2591                                             pad=True,
2592                                             interpreter=interpreter)
2593    dataset = 'avgpooling_1'
2594    testdata_sets[dataset] = PoolingSettings(dataset,
2595                                             type_of_test,
2596                                             regenerate_weights,
2597                                             regenerate_input,
2598                                             regenerate_biases,
2599                                             schema_file,
2600                                             channels=3,
2601                                             x_in=9,
2602                                             y_in=5,
2603                                             stride_x=1,
2604                                             stride_y=2,
2605                                             w_x=9,
2606                                             w_y=5,
2607                                             pad=False,
2608                                             interpreter=interpreter)
2609    dataset = 'avgpooling_2'
2610    testdata_sets[dataset] = PoolingSettings(dataset,
2611                                             type_of_test,
2612                                             regenerate_weights,
2613                                             regenerate_input,
2614                                             regenerate_biases,
2615                                             schema_file,
2616                                             channels=5,
2617                                             x_in=12,
2618                                             y_in=1,
2619                                             stride_x=1,
2620                                             stride_y=2,
2621                                             w_x=3,
2622                                             w_y=1,
2623                                             pad=True,
2624                                             interpreter=interpreter)
2625    dataset = 'avgpooling_3'
2626    testdata_sets[dataset] = PoolingSettings(dataset,
2627                                             type_of_test,
2628                                             regenerate_weights,
2629                                             regenerate_input,
2630                                             regenerate_biases,
2631                                             schema_file,
2632                                             channels=2,
2633                                             x_in=9,
2634                                             y_in=1,
2635                                             stride_x=2,
2636                                             stride_y=1,
2637                                             w_x=1,
2638                                             w_y=1,
2639                                             batches=2,
2640                                             pad=False,
2641                                             interpreter=interpreter)
2642    dataset = 'avgpooling_4'
2643    testdata_sets[dataset] = PoolingSettings(dataset,
2644                                             type_of_test,
2645                                             regenerate_weights,
2646                                             regenerate_input,
2647                                             regenerate_biases,
2648                                             schema_file,
2649                                             channels=2,
2650                                             x_in=1,
2651                                             y_in=20,
2652                                             stride_x=1,
2653                                             stride_y=3,
2654                                             w_x=1,
2655                                             w_y=3,
2656                                             batches=3,
2657                                             pad=True,
2658                                             interpreter=interpreter)
2659    dataset = 'avgpooling_5'
2660    testdata_sets[dataset] = PoolingSettings(dataset,
2661                                             type_of_test,
2662                                             regenerate_weights,
2663                                             regenerate_input,
2664                                             regenerate_biases,
2665                                             schema_file,
2666                                             channels=1,
2667                                             x_in=3,
2668                                             y_in=3,
2669                                             stride_x=1,
2670                                             stride_y=1,
2671                                             w_x=1,
2672                                             w_y=3,
2673                                             pad=True,
2674                                             relu6=True,
2675                                             interpreter=interpreter)
2676    dataset = 'avgpooling_int16'
2677    testdata_sets[dataset] = PoolingSettings(dataset,
2678                                             type_of_test,
2679                                             regenerate_weights,
2680                                             regenerate_input,
2681                                             regenerate_biases,
2682                                             schema_file,
2683                                             channels=17,
2684                                             x_in=6,
2685                                             y_in=4,
2686                                             stride_x=2,
2687                                             stride_y=1,
2688                                             w_x=2,
2689                                             w_y=3,
2690                                             pad=True,
2691                                             randmin=TestSettings.INT16_MIN,
2692                                             randmax=TestSettings.INT16_MAX,
2693                                             int16xint8=True,
2694                                             interpreter=interpreter)
2695    dataset = 'avgpooling_int16_1'
2696    testdata_sets[dataset] = PoolingSettings(dataset,
2697                                             type_of_test,
2698                                             regenerate_weights,
2699                                             regenerate_input,
2700                                             regenerate_biases,
2701                                             schema_file,
2702                                             channels=2,
2703                                             x_in=9,
2704                                             y_in=1,
2705                                             stride_x=2,
2706                                             stride_y=1,
2707                                             w_x=1,
2708                                             w_y=1,
2709                                             batches=3,
2710                                             pad=False,
2711                                             randmin=TestSettings.INT16_MIN,
2712                                             randmax=TestSettings.INT16_MAX,
2713                                             int16xint8=True,
2714                                             interpreter=interpreter)
2715    dataset = 'avgpooling_int16_2'
2716    testdata_sets[dataset] = PoolingSettings(dataset,
2717                                             type_of_test,
2718                                             regenerate_weights,
2719                                             regenerate_input,
2720                                             regenerate_biases,
2721                                             schema_file,
2722                                             channels=20,
2723                                             x_in=9,
2724                                             y_in=1,
2725                                             stride_x=2,
2726                                             stride_y=1,
2727                                             w_x=1,
2728                                             w_y=1,
2729                                             pad=False,
2730                                             randmin=TestSettings.INT16_MIN,
2731                                             randmax=TestSettings.INT16_MAX,
2732                                             int16xint8=True,
2733                                             interpreter=interpreter)
2734    dataset = 'avgpooling_int16_3'
2735    testdata_sets[dataset] = PoolingSettings(dataset,
2736                                             type_of_test,
2737                                             regenerate_weights,
2738                                             regenerate_input,
2739                                             regenerate_biases,
2740                                             schema_file,
2741                                             channels=21,
2742                                             x_in=1,
2743                                             y_in=20,
2744                                             stride_x=1,
2745                                             stride_y=3,
2746                                             w_x=1,
2747                                             w_y=3,
2748                                             pad=True,
2749                                             randmin=TestSettings.INT16_MIN,
2750                                             randmax=TestSettings.INT16_MAX,
2751                                             int16xint8=True,
2752                                             interpreter=interpreter)
2753
2754    type_of_test = 'maxpool'
2755    dataset = 'maxpooling'
2756    testdata_sets[dataset] = PoolingSettings(dataset,
2757                                             type_of_test,
2758                                             regenerate_weights,
2759                                             regenerate_input,
2760                                             regenerate_biases,
2761                                             schema_file,
2762                                             channels=8,
2763                                             x_in=22,
2764                                             y_in=12,
2765                                             stride_x=9,
2766                                             stride_y=5,
2767                                             w_x=6,
2768                                             w_y=5,
2769                                             batches=2,
2770                                             pad=True,
2771                                             interpreter=interpreter)
2772    dataset = 'maxpooling_1'
2773    testdata_sets[dataset] = PoolingSettings(dataset,
2774                                             type_of_test,
2775                                             regenerate_weights,
2776                                             regenerate_input,
2777                                             regenerate_biases,
2778                                             schema_file,
2779                                             channels=3,
2780                                             x_in=9,
2781                                             y_in=5,
2782                                             stride_x=1,
2783                                             stride_y=2,
2784                                             w_x=9,
2785                                             w_y=5,
2786                                             pad=False,
2787                                             interpreter=interpreter)
2788    dataset = 'maxpooling_2'
2789    testdata_sets[dataset] = PoolingSettings(dataset,
2790                                             type_of_test,
2791                                             regenerate_weights,
2792                                             regenerate_input,
2793                                             regenerate_biases,
2794                                             schema_file,
2795                                             channels=5,
2796                                             x_in=12,
2797                                             y_in=1,
2798                                             stride_x=1,
2799                                             stride_y=2,
2800                                             w_x=3,
2801                                             w_y=1,
2802                                             pad=True,
2803                                             interpreter=interpreter)
2804    dataset = 'maxpooling_3'
2805    testdata_sets[dataset] = PoolingSettings(dataset,
2806                                             type_of_test,
2807                                             regenerate_weights,
2808                                             regenerate_input,
2809                                             regenerate_biases,
2810                                             schema_file,
2811                                             channels=2,
2812                                             x_in=9,
2813                                             y_in=1,
2814                                             stride_x=2,
2815                                             stride_y=1,
2816                                             w_x=1,
2817                                             w_y=1,
2818                                             batches=3,
2819                                             pad=False,
2820                                             interpreter=interpreter)
2821    dataset = 'maxpooling_4'
2822    testdata_sets[dataset] = PoolingSettings(dataset,
2823                                             type_of_test,
2824                                             regenerate_weights,
2825                                             regenerate_input,
2826                                             regenerate_biases,
2827                                             schema_file,
2828                                             channels=2,
2829                                             x_in=1,
2830                                             y_in=20,
2831                                             stride_x=1,
2832                                             stride_y=3,
2833                                             w_x=1,
2834                                             w_y=3,
2835                                             pad=True,
2836                                             interpreter=interpreter)
2837    dataset = 'maxpooling_5'
2838    testdata_sets[dataset] = PoolingSettings(dataset,
2839                                             type_of_test,
2840                                             regenerate_weights,
2841                                             regenerate_input,
2842                                             regenerate_biases,
2843                                             schema_file,
2844                                             channels=20,
2845                                             x_in=1,
2846                                             y_in=1,
2847                                             stride_x=1,
2848                                             stride_y=1,
2849                                             w_x=1,
2850                                             w_y=1,
2851                                             pad=True,
2852                                             interpreter=interpreter)
2853    dataset = 'maxpooling_6'
2854    testdata_sets[dataset] = PoolingSettings(dataset,
2855                                             type_of_test,
2856                                             regenerate_weights,
2857                                             regenerate_input,
2858                                             regenerate_biases,
2859                                             schema_file,
2860                                             channels=17,
2861                                             x_in=1,
2862                                             y_in=5,
2863                                             stride_x=1,
2864                                             stride_y=3,
2865                                             w_x=3,
2866                                             w_y=4,
2867                                             pad=True,
2868                                             interpreter=interpreter)
2869    dataset = 'maxpooling_7'
2870    testdata_sets[dataset] = PoolingSettings(dataset,
2871                                             type_of_test,
2872                                             regenerate_weights,
2873                                             regenerate_input,
2874                                             regenerate_biases,
2875                                             schema_file,
2876                                             channels=1,
2877                                             x_in=4,
2878                                             y_in=2,
2879                                             stride_x=2,
2880                                             stride_y=2,
2881                                             w_x=2,
2882                                             w_y=2,
2883                                             pad=False,
2884                                             relu6=True,
2885                                             interpreter=interpreter)
2886    dataset = 'maxpool_int16'
2887    testdata_sets[dataset] = PoolingSettings(dataset,
2888                                             type_of_test,
2889                                             regenerate_weights,
2890                                             regenerate_input,
2891                                             regenerate_biases,
2892                                             schema_file,
2893                                             channels=2,
2894                                             x_in=4,
2895                                             y_in=3,
2896                                             stride_x=2,
2897                                             stride_y=2,
2898                                             w_x=2,
2899                                             w_y=2,
2900                                             batches=3,
2901                                             pad=False,
2902                                             randmin=TestSettings.INT16_MIN,
2903                                             randmax=TestSettings.INT16_MAX,
2904                                             int16xint8=True,
2905                                             interpreter=interpreter)
2906    dataset = 'maxpool_int16_1'
2907    testdata_sets[dataset] = PoolingSettings(dataset,
2908                                             type_of_test,
2909                                             regenerate_weights,
2910                                             regenerate_input,
2911                                             regenerate_biases,
2912                                             schema_file,
2913                                             channels=2,
2914                                             x_in=4,
2915                                             y_in=5,
2916                                             stride_x=2,
2917                                             stride_y=1,
2918                                             w_x=3,
2919                                             w_y=3,
2920                                             batches=2,
2921                                             pad=True,
2922                                             randmin=TestSettings.INT16_MIN,
2923                                             randmax=TestSettings.INT16_MAX,
2924                                             out_activation_min=-30000,
2925                                             out_activation_max=30000,
2926                                             int16xint8=True,
2927                                             interpreter=interpreter)
2928    dataset = 'maxpool_int16_2'
2929    testdata_sets[dataset] = PoolingSettings(dataset,
2930                                             type_of_test,
2931                                             regenerate_weights,
2932                                             regenerate_input,
2933                                             regenerate_biases,
2934                                             schema_file,
2935                                             channels=3,
2936                                             x_in=7,
2937                                             y_in=7,
2938                                             stride_x=1,
2939                                             stride_y=1,
2940                                             w_x=3,
2941                                             w_y=3,
2942                                             pad=False,
2943                                             randmin=TestSettings.INT16_MIN,
2944                                             randmax=TestSettings.INT16_MAX,
2945                                             out_activation_min=-30000,
2946                                             out_activation_max=30000,
2947                                             int16xint8=True,
2948                                             interpreter=interpreter)
2949
2950    type_of_test = 'softmax'
2951    dataset = 'softmax'
2952    testdata_sets[dataset] = SoftmaxSettings(dataset,
2953                                             type_of_test,
2954                                             regenerate_weights,
2955                                             regenerate_input,
2956                                             regenerate_biases,
2957                                             schema_file,
2958                                             x_in=5,
2959                                             y_in=2,
2960                                             interpreter=interpreter)
2961    dataset = 'softmax_s16'
2962    testdata_sets[dataset] = SoftmaxSettings(dataset,
2963                                             type_of_test,
2964                                             regenerate_weights,
2965                                             regenerate_input,
2966                                             regenerate_biases,
2967                                             schema_file,
2968                                             x_in=10,
2969                                             y_in=3,
2970                                             int16xint8=True,
2971                                             randmin=TestSettings.INT16_MIN,
2972                                             randmax=TestSettings.INT16_MAX,
2973                                             interpreter=interpreter)
2974    dataset = 'softmax_s8_s16'
2975    testdata_sets[dataset] = SoftmaxSettings(dataset,
2976                                             type_of_test,
2977                                             regenerate_weights,
2978                                             regenerate_input,
2979                                             regenerate_biases,
2980                                             schema_file,
2981                                             x_in=12,
2982                                             y_in=2,
2983                                             inInt8outInt16=True,
2984                                             interpreter=interpreter)
2985
2986    type_of_test = 'svdf'
2987    dataset = 'svdf'
2988    testdata_sets[dataset] = SVDFSettings(dataset,
2989                                          type_of_test,
2990                                          regenerate_weights,
2991                                          regenerate_input,
2992                                          regenerate_biases,
2993                                          schema_file,
2994                                          batches=2,
2995                                          number_inputs=2,
2996                                          rank=8,
2997                                          memory_size=8,
2998                                          input_size=3,
2999                                          number_units=3,
3000                                          interpreter=interpreter)
3001    dataset = 'svdf_1'
3002    testdata_sets[dataset] = SVDFSettings(dataset,
3003                                          type_of_test,
3004                                          regenerate_weights,
3005                                          regenerate_input,
3006                                          regenerate_biases,
3007                                          schema_file,
3008                                          batches=3,
3009                                          number_inputs=2,
3010                                          rank=1,
3011                                          memory_size=2,
3012                                          input_size=7,
3013                                          number_units=5,
3014                                          interpreter=interpreter)
3015    dataset = 'svdf_2'
3016    testdata_sets[dataset] = SVDFSettings(dataset,
3017                                          type_of_test,
3018                                          regenerate_weights,
3019                                          regenerate_input,
3020                                          regenerate_biases,
3021                                          schema_file,
3022                                          batches=3,
3023                                          number_inputs=2,
3024                                          rank=2,
3025                                          memory_size=2,
3026                                          input_size=7,
3027                                          number_units=5,
3028                                          generate_bias=False,
3029                                          interpreter=interpreter)
3030    dataset = 'svdf_3'
3031    testdata_sets[dataset] = SVDFSettings(dataset,
3032                                          type_of_test,
3033                                          regenerate_weights,
3034                                          regenerate_input,
3035                                          regenerate_biases,
3036                                          schema_file,
3037                                          batches=1,
3038                                          number_inputs=2,
3039                                          rank=1,
3040                                          memory_size=2,
3041                                          input_size=20,
3042                                          number_units=12,
3043                                          generate_bias=False,
3044                                          interpreter=interpreter)
3045    dataset = 'svdf_int8'
3046    testdata_sets[dataset] = SVDFSettings(dataset,
3047                                          type_of_test,
3048                                          regenerate_weights,
3049                                          regenerate_input,
3050                                          regenerate_biases,
3051                                          schema_file,
3052                                          batches=1,
3053                                          number_inputs=2,
3054                                          rank=1,
3055                                          memory_size=2,
3056                                          input_size=20,
3057                                          number_units=12,
3058                                          generate_bias=False,
3059                                          int8_time_weights=True,
3060                                          interpreter=interpreter)
3061    dataset = 'svdf_int8_2'
3062    testdata_sets[dataset] = SVDFSettings(dataset,
3063                                          type_of_test,
3064                                          regenerate_weights,
3065                                          regenerate_input,
3066                                          regenerate_biases,
3067                                          schema_file,
3068                                          batches=2,
3069                                          number_inputs=3,
3070                                          rank=2,
3071                                          memory_size=3,
3072                                          input_size=40,
3073                                          number_units=13,
3074                                          input_zp=-12,
3075                                          int8_time_weights=True,
3076                                          interpreter=interpreter)
3077
3078    type_of_test = 'add'
3079    dataset = 'add'
3080    testdata_sets[dataset] = AddMulSettings(dataset,
3081                                            type_of_test,
3082                                            regenerate_weights,
3083                                            regenerate_input,
3084                                            regenerate_biases,
3085                                            schema_file,
3086                                            channels=8,
3087                                            x_in=4,
3088                                            y_in=4,
3089                                            randmin=TestSettings.INT8_MIN,
3090                                            randmax=TestSettings.INT8_MAX,
3091                                            interpreter=interpreter)
3092    dataset = 'add_s16'
3093    testdata_sets[dataset] = AddMulSettings(dataset,
3094                                            type_of_test,
3095                                            regenerate_weights,
3096                                            regenerate_input,
3097                                            regenerate_biases,
3098                                            schema_file,
3099                                            channels=8,
3100                                            x_in=4,
3101                                            y_in=4,
3102                                            randmin=TestSettings.INT16_MIN,
3103                                            randmax=TestSettings.INT16_MAX,
3104                                            out_activation_min=TestSettings.INT16_MIN,
3105                                            out_activation_max=TestSettings.INT16_MAX,
3106                                            int16xint8=True,
3107                                            interpreter=interpreter)
3108    dataset = 'add_s16_spill'
3109    testdata_sets[dataset] = AddMulSettings(dataset,
3110                                            type_of_test,
3111                                            regenerate_weights,
3112                                            regenerate_input,
3113                                            regenerate_biases,
3114                                            schema_file,
3115                                            channels=7,
3116                                            x_in=5,
3117                                            y_in=3,
3118                                            randmin=TestSettings.INT16_MIN,
3119                                            randmax=TestSettings.INT16_MAX,
3120                                            out_activation_min=-2000,
3121                                            out_activation_max=TestSettings.INT16_MAX,
3122                                            int16xint8=True,
3123                                            interpreter=interpreter)
3124
3125    type_of_test = 'mul'
3126    dataset = 'mul'
3127    testdata_sets[dataset] = AddMulSettings(dataset,
3128                                            type_of_test,
3129                                            regenerate_weights,
3130                                            regenerate_input,
3131                                            regenerate_biases,
3132                                            schema_file,
3133                                            channels=8,
3134                                            x_in=4,
3135                                            y_in=5,
3136                                            randmin=TestSettings.INT8_MIN,
3137                                            randmax=TestSettings.INT8_MAX,
3138                                            interpreter=interpreter)
3139    dataset = 'mul_s16'
3140    testdata_sets[dataset] = AddMulSettings(dataset,
3141                                            type_of_test,
3142                                            regenerate_weights,
3143                                            regenerate_input,
3144                                            regenerate_biases,
3145                                            schema_file,
3146                                            channels=8,
3147                                            x_in=5,
3148                                            y_in=4,
3149                                            randmin=TestSettings.INT16_MIN,
3150                                            randmax=TestSettings.INT16_MAX,
3151                                            out_activation_min=TestSettings.INT16_MIN,
3152                                            out_activation_max=TestSettings.INT16_MAX,
3153                                            int16xint8=True,
3154                                            interpreter=interpreter)
3155    dataset = 'mul_s16_spill'
3156    testdata_sets[dataset] = AddMulSettings(dataset,
3157                                            type_of_test,
3158                                            regenerate_weights,
3159                                            regenerate_input,
3160                                            regenerate_biases,
3161                                            schema_file,
3162                                            channels=7,
3163                                            x_in=5,
3164                                            y_in=7,
3165                                            randmin=TestSettings.INT16_MIN,
3166                                            randmax=TestSettings.INT16_MAX,
3167                                            out_activation_min=TestSettings.INT16_MIN,
3168                                            out_activation_max=1000,
3169                                            int16xint8=True,
3170                                            interpreter=interpreter)
3171
3172    type_of_test = 'lstm'
3173    dataset = 'lstm_1'
3174    testdata_sets[dataset] = LSTMSettings(dataset,
3175                                          type_of_test,
3176                                          regenerate_weights,
3177                                          regenerate_input,
3178                                          regenerate_biases,
3179                                          schema_file,
3180                                          batches=1,
3181                                          time_steps=10,
3182                                          number_inputs=22,
3183                                          number_units=11,
3184                                          time_major=True,
3185                                          interpreter=interpreter)
3186    dataset = 'lstm_2'
3187    testdata_sets[dataset] = LSTMSettings(dataset,
3188                                          type_of_test,
3189                                          regenerate_weights,
3190                                          regenerate_input,
3191                                          regenerate_biases,
3192                                          schema_file,
3193                                          batches=1,
3194                                          time_steps=9,
3195                                          number_inputs=6,
3196                                          number_units=7,
3197                                          time_major=False,
3198                                          interpreter=interpreter)
3199    dataset = 'lstm_one_time_step'
3200    testdata_sets[dataset] = LSTMSettings(dataset,
3201                                          type_of_test,
3202                                          regenerate_weights,
3203                                          regenerate_input,
3204                                          regenerate_biases,
3205                                          schema_file,
3206                                          batches=3,
3207                                          time_steps=1,
3208                                          number_inputs=22,
3209                                          number_units=3,
3210                                          time_major=False,
3211                                          interpreter=interpreter)
3212
3213    return testdata_sets
3214
3215
3216def main():
3217    if version.parse(tf.__version__) < TestSettings.REQUIRED_MINIMUM_TENSORFLOW_VERSION:
3218        print("Unsupported tensorflow version, ", version.parse(tf.__version__))
3219        return 1
3220
3221    args = parse_args()
3222
3223    testdataset = args.dataset
3224    test_type = args.testtype
3225    schema_file = args.schema_file
3226
3227    regenerate_input = args.regenerate_input
3228    regenerate_weights = args.regenerate_weights
3229    regenerate_biases = args.regenerate_biases
3230
3231    if args.regenerate_all:
3232        regenerate_biases = True
3233        regenerate_weights = True
3234        regenerate_input = True
3235
3236    testdata_sets = load_testdata_sets(regenerate_input,
3237                                       regenerate_weights,
3238                                       regenerate_biases,
3239                                       schema_file,
3240                                       args.interpreter)
3241
3242    if args.run_all_testsets:
3243        for testset_name, testset_generator in testdata_sets.items():
3244            if test_type and testset_generator.test_type != test_type:
3245                continue
3246            print("Generating testset {}..".format(testset_name))
3247            testset_generator.generate_data()
3248            print()
3249
3250        # Check that all testsets have been loaded.
3251        found_test_data_sets = []
3252        directory = 'TestCases/TestData'
3253        for dir in next(os.walk(directory))[1]:
3254            found_test_data_sets.append(dir)
3255        for testset_name in found_test_data_sets:
3256            if testset_name not in testdata_sets:
3257                print("WARNING: Testset {} in {} was not loaded".format(testset_name, directory))
3258    elif testdataset:
3259        try:
3260            generator = testdata_sets[testdataset]
3261        except KeyError:
3262            print("WARNING: testset {} not in testset list".format(testdataset))
3263            if test_type == 'conv' or test_type == 'depthwise_conv':
3264                generator = ConvSettings(testdataset, test_type, True, True, True, schema_file)
3265            elif test_type == 'fully_connected':
3266                generator = FullyConnectedSettings(testdataset, test_type, True, True, True, schema_file)
3267            elif test_type == 'avgpool' or test_type == 'maxpool':
3268                generator = PoolingSettings(testdataset, test_type, True, True, True, schema_file)
3269            elif test_type == 'softmax':
3270                generator = SoftmaxSettings(testdataset, test_type, True, True, True, schema_file)
3271            elif test_type == 'svdf':
3272                generator = SVDFSettings(testdataset, test_type, True, True, True, schema_file)
3273            elif test_type == 'add' or test_type == 'mul':
3274                generator = AddMulSettings(testdataset, test_type, True, True, True, schema_file)
3275            elif test_type == 'lstm':
3276                generator = LSTMSettings(testdataset, test_type, True, True, True, schema_file)
3277            else:
3278                raise RuntimeError("Please specify type of test with -t")
3279        generator.generate_data()
3280    else:
3281        raise RuntimeError("Please select testdataset or use --run-all-testsets")
3282    return 0
3283
3284if __name__ == '__main__':
3285    sys.exit(main())
3286