Imported Upstream version 1.18.0
[platform/core/ml/nnfw.git] / compiler / luci / pass / src / QuantizedModelVerifier.test.cpp
1 /*
2  * Copyright (c) 2021 Samsung Electronics Co., Ltd. All Rights Reserved
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include "QuantizedModelVerifier.h"
18
19 #include "luci/Pass/QuantizeWithMinMaxPass.h"
20
21 #include <luci/test/TestIOGraph.h>
22
23 #include <gtest/gtest.h>
24
25 using Type = loco::DataType;
26 using Granularity = luci::QuantizationGranularity;
27
28 namespace
29 {
30
31 /**
32  * @brief A helper function to create dummy const node
33  */
34 template <Type T> luci::CircleConst *create_dummy_const(loco::Graph *g, luci::test::ShapeU32 shape)
35 {
36   auto node = g->nodes()->create<luci::CircleConst>();
37   {
38     node->dtype(T);
39     node->shape(shape);
40     node->size<T>(luci::test::num_elements(shape));
41
42     for (int32_t i = 0; i < luci::test::num_elements(shape); i++)
43     {
44       // DESIGN NOTE
45       //
46       // Filling with any random numbers are fine
47       // Q. Should it include minus numbers?
48       switch (T)
49       {
50         case Type::FLOAT32:
51           // Fill with index
52           node->at<T>(i) = static_cast<float>(i);
53           break;
54         case Type::BOOL:
55           // Fill by flip
56           node->at<T>(i) = (i % 2) ? true : false;
57           break;
58         case Type::U8:
59           // Fill with index
60           node->at<T>(i) = static_cast<uint8_t>(i);
61           break;
62         case Type::S16:
63           // Fill with index
64           node->at<T>(i) = static_cast<int16_t>(i);
65           break;
66       }
67     }
68   }
69
70   return node;
71 }
72
73 /**
74  * @brief A helper function to create const node with value
75  */
76 template <Type DT, typename T>
77 luci::CircleConst *create_const(loco::Graph *g, luci::test::ShapeU32 shape,
78                                 std::initializer_list<T> values)
79 {
80   auto node = g->nodes()->create<luci::CircleConst>();
81   {
82     node->dtype(DT);
83     node->shape(shape);
84     node->size<DT>(luci::test::num_elements(shape));
85
86     assert(values.size() == node->size<DT>());
87
88     uint32_t index = 0;
89     for (auto val : values)
90     {
91       node->at<DT>(index++) = static_cast<T>(val);
92     }
93   }
94
95   return node;
96 }
97
98 void insert_scale_zp(luci::CircleNode *node, float scale, int64_t zp)
99 {
100   auto qparam = node->quantparam();
101   assert(qparam != nullptr); // FIX_CALLER_UNLESS
102   qparam->scale.push_back(scale);
103   qparam->zerop.push_back(zp);
104 }
105
106 void quantize_and_verify(loco::Graph *g, Type quantized_dtype, Granularity granularity)
107 {
108   luci::QuantizeWithMinMaxPass pass(Type::FLOAT32, quantized_dtype, granularity);
109   pass.run(g);
110
111   luci::QuantizedModelVerifier verifier(quantized_dtype, granularity);
112   verifier.verify(g);
113 }
114
115 // Helper function to reduce duplicate test codes
116 // Assumption: g->output()->from() is the target node
117 void quantize_and_verify_with_wrong_type(luci::test::TestIOGraph *g, Type quantized_dtype,
118                                          Granularity granularity, Type wrong_dtype)
119 {
120   luci::QuantizeWithMinMaxPass pass(Type::FLOAT32, quantized_dtype, granularity);
121   pass.run(g->g());
122
123   auto node = loco::must_cast<luci::CircleNode *>(g->output()->from());
124   node->dtype(wrong_dtype);
125
126   luci::QuantizedModelVerifier verifier(quantized_dtype, granularity);
127   verifier.verify(g->g());
128 }
129
130 void quantize_and_verify_with_wrong_type(luci::test::TestIOGraph *g, Type quantized_dtype,
131                                          Granularity granularity, Type wrong_dtype,
132                                          luci::CircleNode *target)
133 {
134   luci::QuantizeWithMinMaxPass pass(Type::FLOAT32, quantized_dtype, granularity);
135   pass.run(g->g());
136
137   target->dtype(wrong_dtype);
138
139   luci::QuantizedModelVerifier verifier(quantized_dtype, granularity);
140   verifier.verify(g->g());
141 }
142
143 // Helper function to reduce duplicate test codes
144 // Assumption: g->output()->from() is the target node
145 void quantize_and_verify_with_wrong_granularity(luci::test::TestIOGraph *g, Type quantized_dtype,
146                                                 Granularity granularity)
147 {
148   luci::QuantizeWithMinMaxPass pass(Type::FLOAT32, quantized_dtype, granularity);
149   pass.run(g->g());
150
151   auto node = loco::must_cast<luci::CircleNode *>(g->output()->from());
152   insert_scale_zp(node, 1.0, 1);
153
154   luci::QuantizedModelVerifier verifier(quantized_dtype, granularity);
155   verifier.verify(g->g());
156 }
157
158 // Helper function to reduce duplicate test codes
159 void quantize_and_verify_with_wrong_granularity(luci::test::TestIOGraph *g, Type quantized_dtype,
160                                                 Granularity granularity, luci::CircleNode *target)
161 {
162   luci::QuantizeWithMinMaxPass pass(Type::FLOAT32, quantized_dtype, granularity);
163   pass.run(g->g());
164
165   insert_scale_zp(target, 1.0, 1);
166
167   luci::QuantizedModelVerifier verifier(quantized_dtype, granularity);
168   verifier.verify(g->g());
169 }
170
171 // Set min/max for all non-const nodes in the graph
172 void set_minmax_to_non_const(loco::Graph *g, float min, float max)
173 {
174   for (auto node : loco::all_nodes(g))
175   {
176     auto const_node = dynamic_cast<luci::CircleConst *>(node);
177     if (const_node != nullptr)
178       continue;
179
180     // Min/Max is not recorded for ArgMax
181     // See MinMaxObserver.cpp in record_minmax module
182     auto argmax_node = dynamic_cast<luci::CircleArgMax *>(node);
183     if (argmax_node != nullptr)
184       continue;
185
186     // Min/Max is not recorded for Split
187     // See MinMaxObserver.cpp in record_minmax module
188     auto split_node = dynamic_cast<luci::CircleSplit *>(node);
189     if (split_node != nullptr)
190       continue;
191
192     // Min/Max is not recorded for SplitV
193     // See MinMaxObserver.cpp in record_minmax module
194     auto splitv_node = dynamic_cast<luci::CircleSplitV *>(node);
195     if (splitv_node != nullptr)
196       continue;
197
198     auto circle_node = loco::must_cast<luci::CircleNode *>(node);
199     auto qparam = std::make_unique<luci::CircleQuantParam>();
200     {
201       qparam->min.emplace_back(min);
202       qparam->max.emplace_back(max);
203     }
204     circle_node->quantparam(std::move(qparam));
205   }
206 }
207
208 /**
209  * @brief Simple Test Graph
210  * @note
211  * The simple test graph's nodes are initialized with
212  * simple shapes and values.
213  */
214 class SimpleTestGraph : public luci::test::TestIOGraph
215 {
216 public:
217   virtual void init(void) = 0;
218 };
219
220 class InstanceNormTestGraph final : public SimpleTestGraph
221 {
222 public:
223   void init(void) override
224   {
225     TestIOGraph::init({32}, {32});
226     _gamma = create_dummy_const<Type::FLOAT32>(g(), {32});
227     _beta = create_dummy_const<Type::FLOAT32>(g(), {32});
228     _instnorm = g()->nodes()->create<luci::CircleInstanceNorm>();
229     {
230       _instnorm->input(input());
231       _instnorm->gamma(_gamma);
232       _instnorm->beta(_beta);
233     }
234     output()->from(_instnorm);
235
236     set_minmax_to_non_const(g(), -1, 1);
237   }
238
239 public:
240   loco::Node *gamma(void) const { return _instnorm->gamma(); }
241   loco::Node *beta(void) const { return _instnorm->beta(); }
242
243 private:
244   luci::CircleInstanceNorm *_instnorm = nullptr;
245   luci::CircleConst *_input = nullptr;
246   luci::CircleConst *_gamma = nullptr;
247   luci::CircleConst *_beta = nullptr;
248 };
249
250 class LogisticTestGraph final : public SimpleTestGraph
251 {
252 public:
253   void init(void) override
254   {
255     TestIOGraph::init({32}, {32});
256     _logistic = g()->nodes()->create<luci::CircleLogistic>();
257     {
258       _logistic->x(input());
259     }
260     output()->from(_logistic);
261
262     set_minmax_to_non_const(g(), -1, 1);
263   }
264
265 private:
266   luci::CircleLogistic *_logistic = nullptr;
267 };
268
269 class LocalResponseNormalizationTestGraph final : public SimpleTestGraph
270 {
271 public:
272   void init(void) override
273   {
274     TestIOGraph::init({1, 2, 2, 32}, {1, 2, 2, 32});
275     _lrn = g()->nodes()->create<luci::CircleLocalResponseNormalization>();
276     {
277       _lrn->input(input());
278     }
279     output()->from(_lrn);
280
281     set_minmax_to_non_const(g(), -1, 1);
282   }
283
284 private:
285   luci::CircleLocalResponseNormalization *_lrn = nullptr;
286 };
287
288 class SoftmaxTestGraph final : public SimpleTestGraph
289 {
290 public:
291   void init(void) override
292   {
293     TestIOGraph::init({32}, {32});
294     _softmax = g()->nodes()->create<luci::CircleSoftmax>();
295     {
296       _softmax->logits(input());
297       _softmax->beta(0.1);
298     }
299     output()->from(_softmax);
300
301     set_minmax_to_non_const(g(), -1, 1);
302   }
303
304 private:
305   luci::CircleSoftmax *_softmax = nullptr;
306 };
307
308 class SpaceToBatchNDTestGraph final : public SimpleTestGraph
309 {
310 public:
311   void init(void) override
312   {
313     TestIOGraph::init({1, 2, 2, 1}, {4, 1, 1, 1});
314     _block_shape = create_dummy_const<Type::S32>(g(), {2});
315     for (uint32_t i = 0; i < 2; i++)
316       _block_shape->at<Type::S32>(i) = 2;
317
318     _paddings = create_dummy_const<Type::S32>(g(), {2, 2});
319     for (uint32_t i = 0; i < 4; i++)
320       _paddings->at<Type::S32>(i) = 0;
321
322     _stob = g()->nodes()->create<luci::CircleSpaceToBatchND>();
323     {
324       _stob->input(input());
325       _stob->block_shape(_block_shape);
326       _stob->paddings(_paddings);
327     }
328     output()->from(_stob);
329
330     set_minmax_to_non_const(g(), -1, 1);
331   }
332
333 private:
334   luci::CircleSpaceToBatchND *_stob = nullptr;
335   luci::CircleConst *_block_shape = nullptr;
336   luci::CircleConst *_paddings = nullptr;
337 };
338
339 class SpaceToDepthTestGraph final : public SimpleTestGraph
340 {
341 public:
342   void init(void) override
343   {
344     TestIOGraph::init({1, 2, 2, 1}, {1, 1, 1, 4});
345     _stod = g()->nodes()->create<luci::CircleSpaceToDepth>();
346     {
347       _stod->input(input());
348       _stod->block_size(2);
349     }
350     output()->from(_stod);
351
352     set_minmax_to_non_const(g(), -1, 1);
353   }
354
355 private:
356   luci::CircleSpaceToDepth *_stod = nullptr;
357 };
358
359 template <Type indexT> class SliceTestGraph final : public SimpleTestGraph
360 {
361 public:
362   void init(void) override
363   {
364     TestIOGraph::init({32}, {32});
365     _begin = g()->nodes()->create<luci::CircleConst>();
366     {
367       _begin->dtype(indexT);
368     }
369     _size = g()->nodes()->create<luci::CircleConst>();
370     {
371       _size->dtype(indexT);
372     }
373     _slice = g()->nodes()->create<luci::CircleSlice>();
374     {
375       _slice->input(input());
376       _slice->begin(_begin);
377       _slice->size(_size);
378     }
379     output()->from(_slice);
380
381     set_minmax_to_non_const(g(), -1, 1);
382   }
383
384 private:
385   luci::CircleSlice *_slice = nullptr;
386   luci::CircleConst *_begin = nullptr;
387   luci::CircleConst *_size = nullptr;
388 };
389
390 class SplitTestGraph final : public luci::test::TestIOGraph
391 {
392 public:
393   void init(void)
394   {
395     TestIOGraph::init({1, 32}, {32});
396     _split_dim = create_dummy_const<Type::S32>(g(), {1});
397     _split = g()->nodes()->create<luci::CircleSplit>();
398     {
399       _split->input(input());
400       _split->split_dim(_split_dim);
401     }
402     _split_o1 = g()->nodes()->create<luci::CircleSplitOut>();
403     {
404       _split_o1->input(_split);
405       _split_o1->index(0);
406     }
407
408     output()->from(_split_o1);
409
410     set_minmax_to_non_const(g(), -1, 1);
411   }
412
413 private:
414   luci::CircleSplit *_split = nullptr;
415   luci::CircleSplitOut *_split_o1 = nullptr;
416   luci::CircleConst *_split_dim = nullptr;
417 };
418
419 class SplitVTestGraph final : public luci::test::TestIOGraph
420 {
421 public:
422   void init(void)
423   {
424     TestIOGraph::init({1, 32}, {32});
425     _size_splits = create_dummy_const<Type::S32>(g(), {1});
426     _split_dim = create_dummy_const<Type::S32>(g(), {1});
427     _splitv = g()->nodes()->create<luci::CircleSplitV>();
428     {
429       _splitv->input(input());
430       _splitv->size_splits(_size_splits);
431       _splitv->split_dim(_split_dim);
432     }
433     _splitv_o1 = g()->nodes()->create<luci::CircleSplitVOut>();
434     {
435       _splitv_o1->input(_splitv);
436       _splitv_o1->index(0);
437     }
438
439     output()->from(_splitv_o1);
440
441     set_minmax_to_non_const(g(), -1, 1);
442   }
443
444 private:
445   luci::CircleSplitV *_splitv = nullptr;
446   luci::CircleSplitVOut *_splitv_o1 = nullptr;
447   luci::CircleConst *_size_splits = nullptr;
448   luci::CircleConst *_split_dim = nullptr;
449 };
450
451 class StridedSliceTestGraph final : public SimpleTestGraph
452 {
453 public:
454   void init(void) override
455   {
456     TestIOGraph::init({32}, {32});
457     _begin = g()->nodes()->create<luci::CircleConst>();
458     {
459       _begin->dtype(Type::S32);
460     }
461     _end = g()->nodes()->create<luci::CircleConst>();
462     {
463       _end->dtype(Type::S32);
464     }
465     _strides = g()->nodes()->create<luci::CircleConst>();
466     {
467       _strides->dtype(Type::S32);
468     }
469     _slice = g()->nodes()->create<luci::CircleStridedSlice>();
470     {
471       _slice->input(input());
472       _slice->begin(_begin);
473       _slice->end(_end);
474       _slice->strides(_strides);
475     }
476     output()->from(_slice);
477
478     set_minmax_to_non_const(g(), -1, 1);
479   }
480
481 private:
482   luci::CircleStridedSlice *_slice = nullptr;
483   luci::CircleConst *_begin = nullptr;
484   luci::CircleConst *_end = nullptr;
485   luci::CircleConst *_strides = nullptr;
486 };
487
488 class ReshapeTestGraph final : public SimpleTestGraph
489 {
490 public:
491   void init(void) override
492   {
493     TestIOGraph::init({32}, {32});
494     _shape = g()->nodes()->create<luci::CircleConst>();
495     {
496       _shape->dtype(Type::S32);
497     }
498     _reshape = g()->nodes()->create<luci::CircleReshape>();
499     {
500       _reshape->tensor(input());
501       _reshape->shape(_shape);
502     }
503     output()->from(_reshape);
504
505     set_minmax_to_non_const(g(), -1, 1);
506   }
507
508 private:
509   luci::CircleReshape *_reshape = nullptr;
510   luci::CircleConst *_shape = nullptr;
511 };
512
513 class TanhTestGraph final : public SimpleTestGraph
514 {
515 public:
516   void init(void) override
517   {
518     TestIOGraph::init({32}, {32});
519     _tanh = g()->nodes()->create<luci::CircleTanh>();
520     {
521       _tanh->x(input());
522     }
523     output()->from(_tanh);
524
525     set_minmax_to_non_const(g(), -1, 1);
526   }
527
528 private:
529   luci::CircleTanh *_tanh = nullptr;
530 };
531
532 class FloorTestGraph final : public SimpleTestGraph
533 {
534 public:
535   void init(void) override
536   {
537     TestIOGraph::init({32}, {32});
538     _floor = g()->nodes()->create<luci::CircleFloor>();
539     {
540       _floor->x(input());
541     }
542     output()->from(_floor);
543
544     set_minmax_to_non_const(g(), -1, 1);
545   }
546
547 private:
548   luci::CircleFloor *_floor = nullptr;
549 };
550
551 template <Type indexT> class ArgMaxTestGraph final : public SimpleTestGraph
552 {
553 public:
554   void init(void) override
555   {
556     TestIOGraph::init({32}, {1});
557     // output dtype is float by default, but ArgMax should have indexType (s32/s64)
558     output()->dtype(indexT);
559     _dimension = g()->nodes()->create<luci::CircleConst>();
560     {
561       _dimension->dtype(indexT);
562     }
563     _argmax = g()->nodes()->create<luci::CircleArgMax>();
564     {
565       _argmax->input(input());
566       _argmax->dimension(_dimension);
567       _argmax->output_type(indexT);
568       _argmax->dtype(indexT);
569     }
570     output()->from(_argmax);
571
572     set_minmax_to_non_const(g(), -1, 1);
573   }
574
575 public:
576   // NOTE: Do not override `luci::CircleNode* input(void)` incidentally
577   loco::Node *input_argmax(void) { return _argmax->input(); }
578   loco::Node *dimension(void) { return _argmax->dimension(); }
579
580 private:
581   luci::CircleArgMax *_argmax = nullptr;
582   luci::CircleConst *_dimension = nullptr;
583 };
584
585 class BatchToSpaceNDTestGraph final : public SimpleTestGraph
586 {
587 public:
588   void init(void) override
589   {
590     TestIOGraph::init({32}, {32});
591     _block_shape = g()->nodes()->create<luci::CircleConst>();
592     {
593       _block_shape->dtype(Type::S32);
594     }
595     _crops = g()->nodes()->create<luci::CircleConst>();
596     {
597       _crops->dtype(Type::S32);
598     }
599     _btos = g()->nodes()->create<luci::CircleBatchToSpaceND>();
600     {
601       _btos->input(input());
602       _btos->block_shape(_block_shape);
603       _btos->crops(_crops);
604     }
605     output()->from(_btos);
606
607     set_minmax_to_non_const(g(), -1, 1);
608   }
609
610 private:
611   luci::CircleBatchToSpaceND *_btos = nullptr;
612   luci::CircleConst *_block_shape = nullptr;
613   luci::CircleConst *_crops = nullptr;
614 };
615
616 class DepthToSpaceTestGraph final : public SimpleTestGraph
617 {
618 public:
619   void init(void) override
620   {
621     TestIOGraph::init({1, 1, 1, 4}, {1, 2, 2, 1});
622     _dtos = g()->nodes()->create<luci::CircleDepthToSpace>();
623     {
624       _dtos->input(input());
625       _dtos->block_size(2);
626     }
627     output()->from(_dtos);
628
629     set_minmax_to_non_const(g(), -1, 1);
630   }
631
632 private:
633   luci::CircleDepthToSpace *_dtos = nullptr;
634 };
635
636 class PackTestGraph final : public SimpleTestGraph
637 {
638 public:
639   void init(void) override
640   {
641     TestIOGraph::init({16}, {32});
642     _param = create_dummy_const<Type::FLOAT32>(g(), {16});
643     _pack = g()->nodes()->create<luci::CirclePack>(2);
644     {
645       _pack->values(0, input());
646       _pack->values(1, _param);
647       _pack->axis(0);
648     }
649     output()->from(_pack);
650
651     set_minmax_to_non_const(g(), -1, 1);
652
653     // Set min/max of the input
654     // pack's qparam will be propagted, overwritten to the input
655     auto input = loco::must_cast<luci::CircleNode *>(pack()->values(0));
656     auto qp = input->quantparam();
657     qp->min[0] = -0.5;
658     qp->max[0] = 0.5;
659   }
660
661 public:
662   luci::CirclePack *pack(void) { return _pack; }
663
664 private:
665   luci::CirclePack *_pack = nullptr;
666   luci::CircleConst *_param = nullptr;
667 };
668
669 class PadTestGraph final : public SimpleTestGraph
670 {
671 public:
672   void init(void) override
673   {
674     TestIOGraph::init({32}, {32});
675     _paddings = g()->nodes()->create<luci::CircleConst>();
676     {
677       _paddings->dtype(Type::S32);
678     }
679     _pad = g()->nodes()->create<luci::CirclePad>();
680     {
681       _pad->input(input());
682       _pad->paddings(_paddings);
683     }
684     output()->from(_pad);
685
686     set_minmax_to_non_const(g(), -1, 1);
687   }
688
689 private:
690   luci::CirclePad *_pad = nullptr;
691   luci::CircleConst *_paddings = nullptr;
692 };
693
694 class PadV2TestGraph final : public SimpleTestGraph
695 {
696 public:
697   void init(void) override
698   {
699     TestIOGraph::init({32}, {32});
700     _paddings = g()->nodes()->create<luci::CircleConst>();
701     {
702       _paddings->dtype(Type::S32);
703     }
704     _constant_values = create_dummy_const<Type::FLOAT32>(g(), {1});
705     _pad = g()->nodes()->create<luci::CirclePadV2>();
706     {
707       _pad->input(input());
708       _pad->paddings(_paddings);
709       _pad->constant_values(_constant_values);
710     }
711     output()->from(_pad);
712
713     set_minmax_to_non_const(g(), -1, 1);
714   }
715
716 private:
717   luci::CirclePadV2 *_pad = nullptr;
718   luci::CircleConst *_paddings = nullptr;
719   luci::CircleConst *_constant_values = nullptr;
720 };
721
722 class MirrorPadTestGraph final : public SimpleTestGraph
723 {
724 public:
725   void init(void) override
726   {
727     TestIOGraph::init({32}, {32});
728     _paddings = g()->nodes()->create<luci::CircleConst>();
729     {
730       _paddings->dtype(Type::S32);
731     }
732     _constant_values = create_dummy_const<Type::FLOAT32>(g(), {1});
733     _mirror_pad = g()->nodes()->create<luci::CircleMirrorPad>();
734     {
735       _mirror_pad->input(input());
736       _mirror_pad->paddings(_paddings);
737       _mirror_pad->mode(luci::MirrorPadMode::REFLECT);
738     }
739     output()->from(_mirror_pad);
740
741     set_minmax_to_non_const(g(), -1, 1);
742   }
743
744 private:
745   luci::CircleMirrorPad *_mirror_pad = nullptr;
746   luci::CircleConst *_paddings = nullptr;
747   luci::CircleConst *_constant_values = nullptr;
748 };
749
750 class TransposeTestGraph final : public SimpleTestGraph
751 {
752 public:
753   void init(void) override
754   {
755     TestIOGraph::init({32}, {32});
756     _perm = g()->nodes()->create<luci::CircleConst>();
757     {
758       _perm->dtype(Type::S32);
759     }
760     _transpose = g()->nodes()->create<luci::CircleTranspose>();
761     {
762       _transpose->a(input());
763       _transpose->perm(_perm);
764     }
765     output()->from(_transpose);
766
767     set_minmax_to_non_const(g(), -1, 1);
768   }
769
770 private:
771   luci::CircleTranspose *_transpose = nullptr;
772   luci::CircleConst *_perm = nullptr;
773 };
774
775 class ConcatenationTestGraph final : public SimpleTestGraph
776 {
777 public:
778   void init(void) override
779   {
780     TestIOGraph::init({16}, {32});
781     _param = create_dummy_const<Type::FLOAT32>(g(), {16});
782     _concat = g()->nodes()->create<luci::CircleConcatenation>(2);
783     {
784       _concat->values(0, input());
785       _concat->values(1, _param);
786       _concat->axis(0);
787     }
788     output()->from(_concat);
789
790     set_minmax_to_non_const(g(), -1, 1);
791   }
792
793 private:
794   luci::CircleConcatenation *_concat = nullptr;
795   luci::CircleConst *_param = nullptr;
796 };
797
798 // Test graph for comparison Ops
799 // GREATER, GREATER_EQUAL, LESS, LESS_EQUAL, EQUAL, NOT_EQUAL
800 template <class Op> class ComparisonOpTestGraph final : public SimpleTestGraph
801 {
802 public:
803   void init(void) override
804   {
805     TestIOGraph::init({32}, {32});
806     output()->dtype(loco::DataType::BOOL);
807     _y = create_dummy_const<Type::FLOAT32>(g(), {32});
808     _op = g()->nodes()->create<Op>();
809     {
810       _op->x(input());
811       _op->y(_y);
812       _op->dtype(loco::DataType::BOOL);
813     }
814     output()->from(_op);
815
816     set_minmax_to_non_const(g(), -1, 1);
817   }
818
819   loco::Node *x(void) const { return _op->x(); }
820   loco::Node *y(void) const { return _op->y(); }
821
822 private:
823   Op *_op = nullptr;
824   luci::CircleConst *_y = nullptr;
825 };
826
827 // Test graph for binary logical Ops
828 // LOGICAL_OR, LOGICAL_AND
829 template <class Op> class BinaryLogicalOpTestGraph final : public SimpleTestGraph
830 {
831 public:
832   void init(void) override
833   {
834     TestIOGraph::init({32}, {32});
835     input()->dtype(loco::DataType::BOOL);
836     output()->dtype(loco::DataType::BOOL);
837     _y = create_dummy_const<Type::BOOL>(g(), {32});
838     _op = g()->nodes()->create<Op>();
839     {
840       _op->x(input());
841       _op->y(_y);
842       _op->dtype(loco::DataType::BOOL);
843     }
844     output()->from(_op);
845
846     set_minmax_to_non_const(g(), -1, 1);
847   }
848
849   loco::Node *x(void) const { return _op->x(); }
850   loco::Node *y(void) const { return _op->y(); }
851
852 private:
853   Op *_op = nullptr;
854   luci::CircleConst *_y = nullptr;
855 };
856
857 class DivTestGraph final : public SimpleTestGraph
858 {
859 public:
860   void init(void) override
861   {
862     TestIOGraph::init({32}, {32});
863
864     _const = create_dummy_const<Type::FLOAT32>(g(), {32});
865     _div = g()->nodes()->create<luci::CircleDiv>();
866     {
867       _div->x(input());
868       _div->y(_const);
869     }
870     output()->from(_div);
871
872     set_minmax_to_non_const(g(), -1, 1);
873   }
874
875   loco::Node *x() { return _div->x(); }
876
877   loco::Node *y() { return _div->y(); }
878
879 private:
880   luci::CircleDiv *_div = nullptr;
881   luci::CircleConst *_const = nullptr;
882 };
883
884 class FloorDivTestGraph final : public SimpleTestGraph
885 {
886 public:
887   void init(void) override
888   {
889     TestIOGraph::init({32}, {32});
890
891     _const = create_dummy_const<Type::FLOAT32>(g(), {32});
892     _floor_div = g()->nodes()->create<luci::CircleFloorDiv>();
893     {
894       _floor_div->x(input());
895       _floor_div->y(_const);
896     }
897     output()->from(_floor_div);
898
899     set_minmax_to_non_const(g(), -1, 1);
900   }
901
902   loco::Node *x() { return _floor_div->x(); }
903
904   loco::Node *y() { return _floor_div->y(); }
905
906 private:
907   luci::CircleFloorDiv *_floor_div = nullptr;
908   luci::CircleConst *_const = nullptr;
909 };
910
911 class RsqrtTestGraph final : public SimpleTestGraph
912 {
913 public:
914   void init(void) override
915   {
916     TestIOGraph::init({32}, {32});
917     _rsqrt = g()->nodes()->create<luci::CircleRsqrt>();
918     {
919       _rsqrt->x(input());
920     }
921     output()->from(_rsqrt);
922
923     set_minmax_to_non_const(g(), -1, 1);
924   }
925
926 private:
927   luci::CircleRsqrt *_rsqrt = nullptr;
928 };
929
930 class SqrtTestGraph final : public SimpleTestGraph
931 {
932 public:
933   void init(void) override
934   {
935     TestIOGraph::init({32}, {32});
936     _sqrt = g()->nodes()->create<luci::CircleSqrt>();
937     {
938       _sqrt->x(input());
939     }
940     output()->from(_sqrt);
941
942     set_minmax_to_non_const(g(), -1, 1);
943   }
944
945 private:
946   luci::CircleSqrt *_sqrt = nullptr;
947 };
948
949 class EluTestGraph final : public SimpleTestGraph
950 {
951 public:
952   void init(void) override
953   {
954     TestIOGraph::init({32}, {32});
955     _elu = g()->nodes()->create<luci::CircleElu>();
956     {
957       _elu->features(input());
958     }
959     output()->from(_elu);
960
961     set_minmax_to_non_const(g(), -1, 1);
962   }
963
964 private:
965   luci::CircleElu *_elu = nullptr;
966 };
967
968 class PowTestGraph final : public SimpleTestGraph
969 {
970 public:
971   void init(void) override
972   {
973     TestIOGraph::init({32}, {32});
974
975     _const = create_dummy_const<Type::FLOAT32>(g(), {32});
976     _pow = g()->nodes()->create<luci::CirclePow>();
977     {
978       _pow->x(input());
979       _pow->y(_const);
980     }
981     output()->from(_pow);
982
983     set_minmax_to_non_const(g(), -1, 1);
984   }
985
986   loco::Node *x() { return _pow->x(); }
987
988   loco::Node *y() { return _pow->y(); }
989
990 private:
991   luci::CirclePow *_pow = nullptr;
992   luci::CircleConst *_const = nullptr;
993 };
994
995 class ResizeBilinearTestGraph final : public SimpleTestGraph
996 {
997 public:
998   void init(void) override
999   {
1000     TestIOGraph::init({1, 4, 4, 1}, {1, 8, 8, 1});
1001
1002     _size = create_const<Type::S32, int32_t>(g(), {2}, {8, 8});
1003     _resize_bilinear = g()->nodes()->create<luci::CircleResizeBilinear>();
1004     {
1005       _resize_bilinear->input(input());
1006       _resize_bilinear->size(_size);
1007     }
1008     output()->from(_resize_bilinear);
1009
1010     set_minmax_to_non_const(g(), -1, 1);
1011   }
1012
1013 private:
1014   luci::CircleResizeBilinear *_resize_bilinear = nullptr;
1015   luci::CircleConst *_size = nullptr;
1016 };
1017
1018 class ResizeNearestNeighborTestGraph final : public luci::test::TestIOGraph
1019 {
1020 public:
1021   void init(void)
1022   {
1023     TestIOGraph::init({1, 4, 4, 1}, {1, 8, 8, 1});
1024
1025     _size = create_const<Type::S32, int32_t>(g(), {2}, {8, 8});
1026     _resize_nearest_neighbor = g()->nodes()->create<luci::CircleResizeNearestNeighbor>();
1027     {
1028       _resize_nearest_neighbor->input(input());
1029       _resize_nearest_neighbor->size(_size);
1030     }
1031     output()->from(_resize_nearest_neighbor);
1032
1033     set_minmax_to_non_const(g(), -1, 1);
1034   }
1035
1036 private:
1037   luci::CircleResizeNearestNeighbor *_resize_nearest_neighbor = nullptr;
1038   luci::CircleConst *_size = nullptr;
1039 };
1040
1041 class UnpackTestGraph final : public luci::test::TestIOGraph
1042 {
1043 public:
1044   void init(void)
1045   {
1046     TestIOGraph::init({1, 32}, {32});
1047     _unpack = g()->nodes()->create<luci::CircleUnpack>();
1048     {
1049       _unpack->value(input());
1050       _unpack->axis(0);
1051       _unpack->num(1);
1052     }
1053     _unpack_o1 = g()->nodes()->create<luci::CircleUnpackOut>();
1054     {
1055       _unpack_o1->input(_unpack);
1056       _unpack_o1->index(0);
1057     }
1058
1059     output()->from(_unpack_o1);
1060
1061     set_minmax_to_non_const(g(), -1, 1);
1062   }
1063
1064 private:
1065   luci::CircleUnpack *_unpack = nullptr;
1066   luci::CircleUnpackOut *_unpack_o1 = nullptr;
1067   luci::CircleConst *_unpack_dim = nullptr;
1068 };
1069
1070 } // namespace
1071
1072 // Quantize and verify with given configurations
1073 #define TEST_WITH_GRAPH(graph, type, granularity)                   \
1074   do                                                                \
1075   {                                                                 \
1076     graph g;                                                        \
1077     g.init();                                                       \
1078     EXPECT_NO_THROW(quantize_and_verify(g.g(), type, granularity)); \
1079   } while (0)
1080
1081 // Quantize and verify with wrong type
1082 #define TEST_WITH_WRONG_TYPE(graph, type, granularity, wrong_dtype)                            \
1083   do                                                                                           \
1084   {                                                                                            \
1085     graph g;                                                                                   \
1086     g.init();                                                                                  \
1087     EXPECT_ANY_THROW(quantize_and_verify_with_wrong_type(&g, type, granularity, wrong_dtype)); \
1088   } while (0)
1089
1090 // Quantize and verify with wrong granularity
1091 #define TEST_WITH_WRONG_GRANULARITY(graph, type, granularity)                            \
1092   do                                                                                     \
1093   {                                                                                      \
1094     graph g;                                                                             \
1095     g.init();                                                                            \
1096     EXPECT_ANY_THROW(quantize_and_verify_with_wrong_granularity(&g, type, granularity)); \
1097   } while (0)
1098
1099 // Quantize and verify with wrong type
1100 // Users can specify the test target
1101 #define TEST_WITH_WRONG_TYPE_TARGET(graph, type, granularity, wrong_dtype, target)    \
1102   do                                                                                  \
1103   {                                                                                   \
1104     graph g;                                                                          \
1105     g.init();                                                                         \
1106     auto node = loco::must_cast<luci::CircleNode *>(target);                          \
1107     EXPECT_ANY_THROW(                                                                 \
1108       quantize_and_verify_with_wrong_type(&g, type, granularity, wrong_dtype, node)); \
1109   } while (0)
1110
1111 // Quantize and verify with wrong granularity
1112 // Users can specify the test target
1113 #define TEST_WITH_WRONG_GRANULARITY_TARGET(graph, type, granularity, target)                   \
1114   do                                                                                           \
1115   {                                                                                            \
1116     graph g;                                                                                   \
1117     g.init();                                                                                  \
1118     auto node = loco::must_cast<luci::CircleNode *>(target);                                   \
1119     EXPECT_ANY_THROW(quantize_and_verify_with_wrong_granularity(&g, type, granularity, node)); \
1120   } while (0)
1121
1122 // Test a local helper function
1123 TEST(QuantizedModelVerifierTest, LocalCreateDummyConst)
1124 {
1125   loco::Graph g;
1126
1127   EXPECT_NO_THROW(create_dummy_const<Type::FLOAT32>(&g, {32, 32}));
1128 }
1129
1130 TEST(QuantizedModelVerifierTest, LocalCreateConst)
1131 {
1132   loco::Graph g;
1133   std::initializer_list<float> values = {0.1, 0, -5, 100};
1134   luci::CircleConst *node = create_const<Type::FLOAT32, float>(&g, {2, 2}, values);
1135
1136   uint32_t index = 0;
1137   for (auto val : values)
1138   {
1139     EXPECT_EQ(node->at<Type::FLOAT32>(index++), val);
1140   }
1141 }
1142
1143 TEST(QuantizedModelVerifierTest, InstanceNorm)
1144 {
1145   TEST_WITH_GRAPH(InstanceNormTestGraph, Type::U8, Granularity::LayerWise);
1146   TEST_WITH_GRAPH(InstanceNormTestGraph, Type::U8, Granularity::ChannelWise);
1147   TEST_WITH_GRAPH(InstanceNormTestGraph, Type::S16, Granularity::ChannelWise);
1148   SUCCEED();
1149 }
1150
1151 TEST(QuantizedModelVerifierTest, InstanceNorm_wrong_type_NEG)
1152 {
1153   TEST_WITH_WRONG_TYPE(InstanceNormTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1154   TEST_WITH_WRONG_TYPE(InstanceNormTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1155   TEST_WITH_WRONG_TYPE(InstanceNormTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1156   SUCCEED();
1157 }
1158
1159 TEST(QuantizedModelVerifierTest, InstanceNorm_wrong_granularity_NEG)
1160 {
1161   TEST_WITH_WRONG_GRANULARITY(InstanceNormTestGraph, Type::U8, Granularity::LayerWise);
1162   TEST_WITH_WRONG_GRANULARITY(InstanceNormTestGraph, Type::U8, Granularity::ChannelWise);
1163   TEST_WITH_WRONG_GRANULARITY(InstanceNormTestGraph, Type::S16, Granularity::ChannelWise);
1164   SUCCEED();
1165 }
1166
1167 TEST(QuantizedModelVerifierTest, LocalResponseNormalization)
1168 {
1169   TEST_WITH_GRAPH(LocalResponseNormalizationTestGraph, Type::U8, Granularity::LayerWise);
1170   TEST_WITH_GRAPH(LocalResponseNormalizationTestGraph, Type::U8, Granularity::ChannelWise);
1171   TEST_WITH_GRAPH(LocalResponseNormalizationTestGraph, Type::S16, Granularity::ChannelWise);
1172   SUCCEED();
1173 }
1174
1175 TEST(QuantizedModelVerifierTest, LocalResponseNormalization_wrong_type_NEG)
1176 {
1177   TEST_WITH_WRONG_TYPE(LocalResponseNormalizationTestGraph, Type::U8, Granularity::LayerWise,
1178                        Type::S16);
1179   TEST_WITH_WRONG_TYPE(LocalResponseNormalizationTestGraph, Type::U8, Granularity::ChannelWise,
1180                        Type::S16);
1181   TEST_WITH_WRONG_TYPE(LocalResponseNormalizationTestGraph, Type::S16, Granularity::ChannelWise,
1182                        Type::U8);
1183   SUCCEED();
1184 }
1185
1186 TEST(QuantizedModelVerifierTest, LocalResponseNormalization_wrong_granularity_NEG)
1187 {
1188   TEST_WITH_WRONG_GRANULARITY(LocalResponseNormalizationTestGraph, Type::U8,
1189                               Granularity::LayerWise);
1190   TEST_WITH_WRONG_GRANULARITY(LocalResponseNormalizationTestGraph, Type::U8,
1191                               Granularity::ChannelWise);
1192   TEST_WITH_WRONG_GRANULARITY(LocalResponseNormalizationTestGraph, Type::S16,
1193                               Granularity::ChannelWise);
1194   SUCCEED();
1195 }
1196
1197 TEST(QuantizedModelVerifierTest, Logistic)
1198 {
1199   TEST_WITH_GRAPH(LogisticTestGraph, Type::U8, Granularity::LayerWise);
1200   TEST_WITH_GRAPH(LogisticTestGraph, Type::U8, Granularity::ChannelWise);
1201   TEST_WITH_GRAPH(LogisticTestGraph, Type::S16, Granularity::ChannelWise);
1202   SUCCEED();
1203 }
1204
1205 TEST(QuantizedModelVerifierTest, Logistic_wrong_type_NEG)
1206 {
1207   TEST_WITH_WRONG_TYPE(LogisticTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1208   TEST_WITH_WRONG_TYPE(LogisticTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1209   TEST_WITH_WRONG_TYPE(LogisticTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1210   SUCCEED();
1211 }
1212
1213 TEST(QuantizedModelVerifierTest, Logistic_wrong_granularity_NEG)
1214 {
1215   TEST_WITH_WRONG_GRANULARITY(LogisticTestGraph, Type::U8, Granularity::LayerWise);
1216   TEST_WITH_WRONG_GRANULARITY(LogisticTestGraph, Type::U8, Granularity::ChannelWise);
1217   TEST_WITH_WRONG_GRANULARITY(LogisticTestGraph, Type::S16, Granularity::ChannelWise);
1218   SUCCEED();
1219 }
1220
1221 TEST(QuantizedModelVerifierTest, Softmax)
1222 {
1223   TEST_WITH_GRAPH(SoftmaxTestGraph, Type::U8, Granularity::LayerWise);
1224   TEST_WITH_GRAPH(SoftmaxTestGraph, Type::U8, Granularity::ChannelWise);
1225   TEST_WITH_GRAPH(SoftmaxTestGraph, Type::S16, Granularity::ChannelWise);
1226   SUCCEED();
1227 }
1228
1229 TEST(QuantizedModelVerifierTest, Softmax_wrong_type_NEG)
1230 {
1231   TEST_WITH_WRONG_TYPE(SoftmaxTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1232   TEST_WITH_WRONG_TYPE(SoftmaxTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1233   TEST_WITH_WRONG_TYPE(SoftmaxTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1234   SUCCEED();
1235 }
1236
1237 TEST(QuantizedModelVerifierTest, Softmax_wrong_granularity_NEG)
1238 {
1239   TEST_WITH_WRONG_GRANULARITY(SoftmaxTestGraph, Type::U8, Granularity::LayerWise);
1240   TEST_WITH_WRONG_GRANULARITY(SoftmaxTestGraph, Type::U8, Granularity::ChannelWise);
1241   TEST_WITH_WRONG_GRANULARITY(SoftmaxTestGraph, Type::S16, Granularity::ChannelWise);
1242   SUCCEED();
1243 }
1244
1245 TEST(QuantizedModelVerifierTest, SpaceToBatchND)
1246 {
1247   TEST_WITH_GRAPH(SpaceToBatchNDTestGraph, Type::U8, Granularity::LayerWise);
1248   TEST_WITH_GRAPH(SpaceToBatchNDTestGraph, Type::U8, Granularity::ChannelWise);
1249   TEST_WITH_GRAPH(SpaceToBatchNDTestGraph, Type::S16, Granularity::ChannelWise);
1250   SUCCEED();
1251 }
1252
1253 TEST(QuantizedModelVerifierTest, SpaceToBatchND_wrong_type_NEG)
1254 {
1255   TEST_WITH_WRONG_TYPE(SpaceToBatchNDTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1256   TEST_WITH_WRONG_TYPE(SpaceToBatchNDTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1257   TEST_WITH_WRONG_TYPE(SpaceToBatchNDTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1258   SUCCEED();
1259 }
1260
1261 TEST(QuantizedModelVerifierTest, SpaceToBatchND_wrong_granularity_NEG)
1262 {
1263   TEST_WITH_WRONG_GRANULARITY(SpaceToBatchNDTestGraph, Type::U8, Granularity::LayerWise);
1264   TEST_WITH_WRONG_GRANULARITY(SpaceToBatchNDTestGraph, Type::U8, Granularity::ChannelWise);
1265   TEST_WITH_WRONG_GRANULARITY(SpaceToBatchNDTestGraph, Type::S16, Granularity::ChannelWise);
1266   SUCCEED();
1267 }
1268
1269 TEST(QuantizedModelVerifierTest, SpaceToDepth)
1270 {
1271   TEST_WITH_GRAPH(SpaceToDepthTestGraph, Type::U8, Granularity::LayerWise);
1272   TEST_WITH_GRAPH(SpaceToDepthTestGraph, Type::U8, Granularity::ChannelWise);
1273   TEST_WITH_GRAPH(SpaceToDepthTestGraph, Type::S16, Granularity::ChannelWise);
1274   SUCCEED();
1275 }
1276
1277 TEST(QuantizedModelVerifierTest, SpaceToDepth_wrong_type_NEG)
1278 {
1279   TEST_WITH_WRONG_TYPE(SpaceToDepthTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1280   TEST_WITH_WRONG_TYPE(SpaceToDepthTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1281   TEST_WITH_WRONG_TYPE(SpaceToDepthTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1282   SUCCEED();
1283 }
1284
1285 TEST(QuantizedModelVerifierTest, SpaceToDepth_wrong_granularity_NEG)
1286 {
1287   TEST_WITH_WRONG_GRANULARITY(SpaceToDepthTestGraph, Type::U8, Granularity::LayerWise);
1288   TEST_WITH_WRONG_GRANULARITY(SpaceToDepthTestGraph, Type::U8, Granularity::ChannelWise);
1289   TEST_WITH_WRONG_GRANULARITY(SpaceToDepthTestGraph, Type::S16, Granularity::ChannelWise);
1290   SUCCEED();
1291 }
1292
1293 TEST(QuantizedModelVerifierTest, Slice)
1294 {
1295   TEST_WITH_GRAPH(SliceTestGraph<Type::S32>, Type::U8, Granularity::LayerWise);
1296   TEST_WITH_GRAPH(SliceTestGraph<Type::S32>, Type::U8, Granularity::ChannelWise);
1297   TEST_WITH_GRAPH(SliceTestGraph<Type::S32>, Type::S16, Granularity::ChannelWise);
1298
1299   TEST_WITH_GRAPH(SliceTestGraph<Type::S64>, Type::U8, Granularity::LayerWise);
1300   TEST_WITH_GRAPH(SliceTestGraph<Type::S64>, Type::U8, Granularity::ChannelWise);
1301   TEST_WITH_GRAPH(SliceTestGraph<Type::S64>, Type::S16, Granularity::ChannelWise);
1302   SUCCEED();
1303 }
1304
1305 TEST(QuantizedModelVerifierTest, Slice_wrong_type_NEG)
1306 {
1307   TEST_WITH_WRONG_TYPE(SliceTestGraph<Type::S32>, Type::U8, Granularity::LayerWise, Type::S16);
1308   TEST_WITH_WRONG_TYPE(SliceTestGraph<Type::S32>, Type::U8, Granularity::ChannelWise, Type::S16);
1309   TEST_WITH_WRONG_TYPE(SliceTestGraph<Type::S32>, Type::S16, Granularity::ChannelWise, Type::U8);
1310
1311   TEST_WITH_WRONG_TYPE(SliceTestGraph<Type::S64>, Type::U8, Granularity::LayerWise, Type::S16);
1312   TEST_WITH_WRONG_TYPE(SliceTestGraph<Type::S64>, Type::U8, Granularity::ChannelWise, Type::S16);
1313   TEST_WITH_WRONG_TYPE(SliceTestGraph<Type::S64>, Type::S16, Granularity::ChannelWise, Type::U8);
1314   SUCCEED();
1315 }
1316
1317 TEST(QuantizedModelVerifierTest, Slice_wrong_granularity_NEG)
1318 {
1319   TEST_WITH_WRONG_GRANULARITY(SliceTestGraph<Type::S32>, Type::U8, Granularity::LayerWise);
1320   TEST_WITH_WRONG_GRANULARITY(SliceTestGraph<Type::S32>, Type::U8, Granularity::ChannelWise);
1321   TEST_WITH_WRONG_GRANULARITY(SliceTestGraph<Type::S32>, Type::S16, Granularity::ChannelWise);
1322
1323   TEST_WITH_WRONG_GRANULARITY(SliceTestGraph<Type::S64>, Type::U8, Granularity::LayerWise);
1324   TEST_WITH_WRONG_GRANULARITY(SliceTestGraph<Type::S64>, Type::U8, Granularity::ChannelWise);
1325   TEST_WITH_WRONG_GRANULARITY(SliceTestGraph<Type::S64>, Type::S16, Granularity::ChannelWise);
1326   SUCCEED();
1327 }
1328
1329 TEST(QuantizedModelVerifierTest, Split)
1330 {
1331   TEST_WITH_GRAPH(SplitTestGraph, Type::U8, Granularity::LayerWise);
1332   TEST_WITH_GRAPH(SplitTestGraph, Type::U8, Granularity::ChannelWise);
1333   TEST_WITH_GRAPH(SplitTestGraph, Type::S16, Granularity::ChannelWise);
1334   SUCCEED();
1335 }
1336
1337 TEST(QuantizedModelVerifierTest, Split_wrong_type_NEG)
1338 {
1339   TEST_WITH_WRONG_TYPE(SplitTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1340   TEST_WITH_WRONG_TYPE(SplitTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1341   TEST_WITH_WRONG_TYPE(SplitTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1342   SUCCEED();
1343 }
1344
1345 TEST(QuantizedModelVerifierTest, Split_wrong_granularity_NEG)
1346 {
1347   TEST_WITH_WRONG_GRANULARITY(SplitTestGraph, Type::U8, Granularity::LayerWise);
1348   TEST_WITH_WRONG_GRANULARITY(SplitTestGraph, Type::U8, Granularity::ChannelWise);
1349   TEST_WITH_WRONG_GRANULARITY(SplitTestGraph, Type::S16, Granularity::ChannelWise);
1350   SUCCEED();
1351 }
1352
1353 TEST(QuantizedModelVerifierTest, SplitV)
1354 {
1355   TEST_WITH_GRAPH(SplitVTestGraph, Type::U8, Granularity::LayerWise);
1356   TEST_WITH_GRAPH(SplitVTestGraph, Type::U8, Granularity::ChannelWise);
1357   TEST_WITH_GRAPH(SplitVTestGraph, Type::S16, Granularity::ChannelWise);
1358   SUCCEED();
1359 }
1360
1361 TEST(QuantizedModelVerifierTest, SplitV_wrong_type_NEG)
1362 {
1363   TEST_WITH_WRONG_TYPE(SplitVTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1364   TEST_WITH_WRONG_TYPE(SplitVTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1365   TEST_WITH_WRONG_TYPE(SplitVTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1366   SUCCEED();
1367 }
1368
1369 TEST(QuantizedModelVerifierTest, SplitV_wrong_granularity_NEG)
1370 {
1371   TEST_WITH_WRONG_GRANULARITY(SplitVTestGraph, Type::U8, Granularity::LayerWise);
1372   TEST_WITH_WRONG_GRANULARITY(SplitVTestGraph, Type::U8, Granularity::ChannelWise);
1373   TEST_WITH_WRONG_GRANULARITY(SplitVTestGraph, Type::S16, Granularity::ChannelWise);
1374   SUCCEED();
1375 }
1376
1377 TEST(QuantizedModelVerifierTest, StridedSlice)
1378 {
1379   TEST_WITH_GRAPH(StridedSliceTestGraph, Type::U8, Granularity::LayerWise);
1380   TEST_WITH_GRAPH(StridedSliceTestGraph, Type::U8, Granularity::ChannelWise);
1381   TEST_WITH_GRAPH(StridedSliceTestGraph, Type::S16, Granularity::ChannelWise);
1382   SUCCEED();
1383 }
1384
1385 TEST(QuantizedModelVerifierTest, StridedSlice_wrong_type_NEG)
1386 {
1387   TEST_WITH_WRONG_TYPE(StridedSliceTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1388   TEST_WITH_WRONG_TYPE(StridedSliceTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1389   TEST_WITH_WRONG_TYPE(StridedSliceTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1390   SUCCEED();
1391 }
1392
1393 TEST(QuantizedModelVerifierTest, StridedSlice_wrong_granularity_NEG)
1394 {
1395   TEST_WITH_WRONG_GRANULARITY(StridedSliceTestGraph, Type::U8, Granularity::LayerWise);
1396   TEST_WITH_WRONG_GRANULARITY(StridedSliceTestGraph, Type::U8, Granularity::ChannelWise);
1397   TEST_WITH_WRONG_GRANULARITY(StridedSliceTestGraph, Type::S16, Granularity::ChannelWise);
1398   SUCCEED();
1399 }
1400
1401 TEST(QuantizedModelVerifierTest, ArgMax)
1402 {
1403   TEST_WITH_GRAPH(ArgMaxTestGraph<Type::S32>, Type::U8, Granularity::LayerWise);
1404   TEST_WITH_GRAPH(ArgMaxTestGraph<Type::S32>, Type::U8, Granularity::ChannelWise);
1405   TEST_WITH_GRAPH(ArgMaxTestGraph<Type::S32>, Type::S16, Granularity::ChannelWise);
1406
1407   TEST_WITH_GRAPH(ArgMaxTestGraph<Type::S64>, Type::U8, Granularity::LayerWise);
1408   TEST_WITH_GRAPH(ArgMaxTestGraph<Type::S64>, Type::U8, Granularity::ChannelWise);
1409   TEST_WITH_GRAPH(ArgMaxTestGraph<Type::S64>, Type::S16, Granularity::ChannelWise);
1410   SUCCEED();
1411 }
1412
1413 TEST(QuantizedModelVerifierTest, ArgMax_wrong_input_type_NEG)
1414 {
1415   TEST_WITH_WRONG_TYPE(ArgMaxTestGraph<Type::S32>, Type::U8, Granularity::LayerWise, Type::S16);
1416   TEST_WITH_WRONG_TYPE(ArgMaxTestGraph<Type::S32>, Type::U8, Granularity::ChannelWise, Type::S16);
1417   TEST_WITH_WRONG_TYPE(ArgMaxTestGraph<Type::S32>, Type::S16, Granularity::ChannelWise, Type::U8);
1418
1419   TEST_WITH_WRONG_TYPE(ArgMaxTestGraph<Type::S64>, Type::U8, Granularity::LayerWise, Type::S16);
1420   TEST_WITH_WRONG_TYPE(ArgMaxTestGraph<Type::S64>, Type::U8, Granularity::ChannelWise, Type::S16);
1421   TEST_WITH_WRONG_TYPE(ArgMaxTestGraph<Type::S64>, Type::S16, Granularity::ChannelWise, Type::U8);
1422   SUCCEED();
1423 }
1424
1425 TEST(QuantizedModelVerifierTest, ArgMax_wrong_dimension_type_NEG)
1426 {
1427   TEST_WITH_WRONG_TYPE_TARGET(ArgMaxTestGraph<Type::S32>, Type::U8, Granularity::LayerWise,
1428                               Type::S16, g.dimension());
1429   TEST_WITH_WRONG_TYPE_TARGET(ArgMaxTestGraph<Type::S32>, Type::U8, Granularity::ChannelWise,
1430                               Type::S16, g.dimension());
1431   TEST_WITH_WRONG_TYPE_TARGET(ArgMaxTestGraph<Type::S32>, Type::S16, Granularity::ChannelWise,
1432                               Type::U8, g.dimension());
1433
1434   TEST_WITH_WRONG_TYPE_TARGET(ArgMaxTestGraph<Type::S64>, Type::U8, Granularity::LayerWise,
1435                               Type::S16, g.dimension());
1436   TEST_WITH_WRONG_TYPE_TARGET(ArgMaxTestGraph<Type::S64>, Type::U8, Granularity::ChannelWise,
1437                               Type::S16, g.dimension());
1438   TEST_WITH_WRONG_TYPE_TARGET(ArgMaxTestGraph<Type::S64>, Type::S16, Granularity::ChannelWise,
1439                               Type::U8, g.dimension());
1440   SUCCEED();
1441 }
1442
1443 TEST(QuantizedModelVerifierTest, ArgMax_wrong_granularity_NEG)
1444 {
1445   TEST_WITH_WRONG_GRANULARITY_TARGET(ArgMaxTestGraph<Type::S32>, Type::U8, Granularity::LayerWise,
1446                                      g.input_argmax());
1447   TEST_WITH_WRONG_GRANULARITY_TARGET(ArgMaxTestGraph<Type::S32>, Type::U8, Granularity::ChannelWise,
1448                                      g.input_argmax());
1449   TEST_WITH_WRONG_GRANULARITY_TARGET(ArgMaxTestGraph<Type::S32>, Type::S16,
1450                                      Granularity::ChannelWise, g.input_argmax());
1451
1452   TEST_WITH_WRONG_GRANULARITY_TARGET(ArgMaxTestGraph<Type::S64>, Type::U8, Granularity::LayerWise,
1453                                      g.input_argmax());
1454   TEST_WITH_WRONG_GRANULARITY_TARGET(ArgMaxTestGraph<Type::S64>, Type::U8, Granularity::ChannelWise,
1455                                      g.input_argmax());
1456   TEST_WITH_WRONG_GRANULARITY_TARGET(ArgMaxTestGraph<Type::S64>, Type::S16,
1457                                      Granularity::ChannelWise, g.input_argmax());
1458   SUCCEED();
1459 }
1460
1461 TEST(QuantizedModelVerifierTest, BatchToSpaceND)
1462 {
1463   TEST_WITH_GRAPH(BatchToSpaceNDTestGraph, Type::U8, Granularity::LayerWise);
1464   TEST_WITH_GRAPH(BatchToSpaceNDTestGraph, Type::U8, Granularity::ChannelWise);
1465   TEST_WITH_GRAPH(BatchToSpaceNDTestGraph, Type::S16, Granularity::ChannelWise);
1466   SUCCEED();
1467 }
1468
1469 TEST(QuantizedModelVerifierTest, BatchToSpaceND_wrong_type_NEG)
1470 {
1471   TEST_WITH_WRONG_TYPE(BatchToSpaceNDTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1472   TEST_WITH_WRONG_TYPE(BatchToSpaceNDTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1473   TEST_WITH_WRONG_TYPE(BatchToSpaceNDTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1474   SUCCEED();
1475 }
1476
1477 TEST(QuantizedModelVerifierTest, BatchToSpaceND_wrong_granularity_NEG)
1478 {
1479   TEST_WITH_WRONG_GRANULARITY(BatchToSpaceNDTestGraph, Type::U8, Granularity::LayerWise);
1480   TEST_WITH_WRONG_GRANULARITY(BatchToSpaceNDTestGraph, Type::U8, Granularity::ChannelWise);
1481   TEST_WITH_WRONG_GRANULARITY(BatchToSpaceNDTestGraph, Type::S16, Granularity::ChannelWise);
1482   SUCCEED();
1483 }
1484
1485 TEST(QuantizedModelVerifierTest, DepthToSpace)
1486 {
1487   TEST_WITH_GRAPH(DepthToSpaceTestGraph, Type::U8, Granularity::LayerWise);
1488   TEST_WITH_GRAPH(DepthToSpaceTestGraph, Type::U8, Granularity::ChannelWise);
1489   TEST_WITH_GRAPH(DepthToSpaceTestGraph, Type::S16, Granularity::ChannelWise);
1490   SUCCEED();
1491 }
1492
1493 TEST(QuantizedModelVerifierTest, DepthToSpace_wrong_type_NEG)
1494 {
1495   TEST_WITH_WRONG_TYPE(DepthToSpaceTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1496   TEST_WITH_WRONG_TYPE(DepthToSpaceTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1497   TEST_WITH_WRONG_TYPE(DepthToSpaceTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1498   SUCCEED();
1499 }
1500
1501 TEST(QuantizedModelVerifierTest, DepthToSpace_wrong_granularity_NEG)
1502 {
1503   TEST_WITH_WRONG_GRANULARITY(DepthToSpaceTestGraph, Type::U8, Granularity::LayerWise);
1504   TEST_WITH_WRONG_GRANULARITY(DepthToSpaceTestGraph, Type::U8, Granularity::ChannelWise);
1505   TEST_WITH_WRONG_GRANULARITY(DepthToSpaceTestGraph, Type::S16, Granularity::ChannelWise);
1506   SUCCEED();
1507 }
1508
1509 TEST(QuantizedModelVerifierTest, Concatenation)
1510 {
1511   TEST_WITH_GRAPH(ConcatenationTestGraph, Type::U8, Granularity::LayerWise);
1512   TEST_WITH_GRAPH(ConcatenationTestGraph, Type::U8, Granularity::ChannelWise);
1513   TEST_WITH_GRAPH(ConcatenationTestGraph, Type::S16, Granularity::ChannelWise);
1514   SUCCEED();
1515 }
1516
1517 TEST(QuantizedModelVerifierTest, Concatenation_wrong_type_NEG)
1518 {
1519   TEST_WITH_WRONG_TYPE(ConcatenationTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1520   TEST_WITH_WRONG_TYPE(ConcatenationTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1521   TEST_WITH_WRONG_TYPE(ConcatenationTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1522   SUCCEED();
1523 }
1524
1525 TEST(QuantizedModelVerifierTest, Concatenation_wrong_granularity_NEG)
1526 {
1527   TEST_WITH_WRONG_GRANULARITY(ConcatenationTestGraph, Type::U8, Granularity::LayerWise);
1528   TEST_WITH_WRONG_GRANULARITY(ConcatenationTestGraph, Type::U8, Granularity::ChannelWise);
1529   TEST_WITH_WRONG_GRANULARITY(ConcatenationTestGraph, Type::S16, Granularity::ChannelWise);
1530   SUCCEED();
1531 }
1532
1533 TEST(QuantizedModelVerifierTest, LogicalOr)
1534 {
1535   TEST_WITH_GRAPH(BinaryLogicalOpTestGraph<luci::CircleLogicalOr>, Type::U8,
1536                   Granularity::LayerWise);
1537   TEST_WITH_GRAPH(BinaryLogicalOpTestGraph<luci::CircleLogicalOr>, Type::U8,
1538                   Granularity::ChannelWise);
1539   TEST_WITH_GRAPH(BinaryLogicalOpTestGraph<luci::CircleLogicalOr>, Type::S16,
1540                   Granularity::ChannelWise);
1541   SUCCEED();
1542 }
1543
1544 TEST(QuantizedModelVerifierTest, LogicalOr_wrong_type_NEG)
1545 {
1546   TEST_WITH_WRONG_TYPE(BinaryLogicalOpTestGraph<luci::CircleLogicalOr>, Type::U8,
1547                        Granularity::LayerWise, Type::U8);
1548   TEST_WITH_WRONG_TYPE(BinaryLogicalOpTestGraph<luci::CircleLogicalOr>, Type::U8,
1549                        Granularity::ChannelWise, Type::U8);
1550   TEST_WITH_WRONG_TYPE(BinaryLogicalOpTestGraph<luci::CircleLogicalOr>, Type::S16,
1551                        Granularity::ChannelWise, Type::S16);
1552   SUCCEED();
1553 }
1554
1555 TEST(QuantizedModelVerifierTest, Reshape)
1556 {
1557   TEST_WITH_GRAPH(ReshapeTestGraph, Type::U8, Granularity::LayerWise);
1558   TEST_WITH_GRAPH(ReshapeTestGraph, Type::U8, Granularity::ChannelWise);
1559   TEST_WITH_GRAPH(ReshapeTestGraph, Type::S16, Granularity::ChannelWise);
1560   SUCCEED();
1561 }
1562
1563 TEST(QuantizedModelVerifierTest, Reshape_wrong_type_NEG)
1564 {
1565   TEST_WITH_WRONG_TYPE(ReshapeTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1566   TEST_WITH_WRONG_TYPE(ReshapeTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1567   TEST_WITH_WRONG_TYPE(ReshapeTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1568   SUCCEED();
1569 }
1570
1571 TEST(QuantizedModelVerifierTest, Reshape_wrong_granularity_NEG)
1572 {
1573   TEST_WITH_WRONG_GRANULARITY(ReshapeTestGraph, Type::U8, Granularity::LayerWise);
1574   TEST_WITH_WRONG_GRANULARITY(ReshapeTestGraph, Type::U8, Granularity::ChannelWise);
1575   TEST_WITH_WRONG_GRANULARITY(ReshapeTestGraph, Type::S16, Granularity::ChannelWise);
1576   SUCCEED();
1577 }
1578
1579 TEST(QuantizedModelVerifierTest, Tanh)
1580 {
1581   TEST_WITH_GRAPH(TanhTestGraph, Type::U8, Granularity::LayerWise);
1582   TEST_WITH_GRAPH(TanhTestGraph, Type::U8, Granularity::ChannelWise);
1583   TEST_WITH_GRAPH(TanhTestGraph, Type::S16, Granularity::ChannelWise);
1584   SUCCEED();
1585 }
1586
1587 TEST(QuantizedModelVerifierTest, Tanh_wrong_type_NEG)
1588 {
1589   TEST_WITH_WRONG_TYPE(TanhTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1590   TEST_WITH_WRONG_TYPE(TanhTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1591   TEST_WITH_WRONG_TYPE(TanhTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1592   SUCCEED();
1593 }
1594
1595 TEST(QuantizedModelVerifierTest, Tanh_wrong_granularity_NEG)
1596 {
1597   TEST_WITH_WRONG_GRANULARITY(TanhTestGraph, Type::U8, Granularity::LayerWise);
1598   TEST_WITH_WRONG_GRANULARITY(TanhTestGraph, Type::U8, Granularity::ChannelWise);
1599   TEST_WITH_WRONG_GRANULARITY(TanhTestGraph, Type::S16, Granularity::ChannelWise);
1600   SUCCEED();
1601 }
1602
1603 TEST(QuantizedModelVerifierTest, Pack)
1604 {
1605   TEST_WITH_GRAPH(PackTestGraph, Type::U8, Granularity::LayerWise);
1606   TEST_WITH_GRAPH(PackTestGraph, Type::U8, Granularity::ChannelWise);
1607   TEST_WITH_GRAPH(PackTestGraph, Type::S16, Granularity::ChannelWise);
1608
1609   // Test if Pack's qparam is propagated to the input
1610   {
1611     PackTestGraph g;
1612     g.init();
1613     quantize_and_verify(g.g(), Type::U8, Granularity::ChannelWise);
1614     auto input = loco::must_cast<luci::CircleNode *>(g.pack()->values(0));
1615     auto qp = input->quantparam();
1616     EXPECT_FLOAT_EQ(2.0 / 255.0, qp->scale[0]);
1617     EXPECT_FLOAT_EQ(128, qp->zerop[0]);
1618   }
1619   SUCCEED();
1620 }
1621
1622 TEST(QuantizedModelVerifierTest, Pack_wrong_type_NEG)
1623 {
1624   TEST_WITH_WRONG_TYPE(PackTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1625   TEST_WITH_WRONG_TYPE(PackTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1626   TEST_WITH_WRONG_TYPE(PackTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1627   SUCCEED();
1628 }
1629
1630 TEST(QuantizedModelVerifierTest, Pack_wrong_granularity_NEG)
1631 {
1632   TEST_WITH_WRONG_GRANULARITY(PackTestGraph, Type::U8, Granularity::LayerWise);
1633   TEST_WITH_WRONG_GRANULARITY(PackTestGraph, Type::U8, Granularity::ChannelWise);
1634   TEST_WITH_WRONG_GRANULARITY(PackTestGraph, Type::S16, Granularity::ChannelWise);
1635   SUCCEED();
1636 }
1637
1638 TEST(QuantizedModelVerifierTest, Pad)
1639 {
1640   TEST_WITH_GRAPH(PadTestGraph, Type::U8, Granularity::LayerWise);
1641   TEST_WITH_GRAPH(PadTestGraph, Type::U8, Granularity::ChannelWise);
1642   TEST_WITH_GRAPH(PadTestGraph, Type::S16, Granularity::ChannelWise);
1643   SUCCEED();
1644 }
1645
1646 TEST(QuantizedModelVerifierTest, Pad_wrong_type_NEG)
1647 {
1648   TEST_WITH_WRONG_TYPE(PadTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1649   TEST_WITH_WRONG_TYPE(PadTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1650   TEST_WITH_WRONG_TYPE(PadTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1651   SUCCEED();
1652 }
1653
1654 TEST(QuantizedModelVerifierTest, Pad_wrong_granularity_NEG)
1655 {
1656   TEST_WITH_WRONG_GRANULARITY(PadTestGraph, Type::U8, Granularity::LayerWise);
1657   TEST_WITH_WRONG_GRANULARITY(PadTestGraph, Type::U8, Granularity::ChannelWise);
1658   TEST_WITH_WRONG_GRANULARITY(PadTestGraph, Type::S16, Granularity::ChannelWise);
1659   SUCCEED();
1660 }
1661
1662 TEST(QuantizedModelVerifierTest, PadV2)
1663 {
1664   TEST_WITH_GRAPH(PadV2TestGraph, Type::U8, Granularity::LayerWise);
1665   TEST_WITH_GRAPH(PadV2TestGraph, Type::U8, Granularity::ChannelWise);
1666   TEST_WITH_GRAPH(PadV2TestGraph, Type::S16, Granularity::ChannelWise);
1667   SUCCEED();
1668 }
1669
1670 TEST(QuantizedModelVerifierTest, PadV2_wrong_type_NEG)
1671 {
1672   TEST_WITH_WRONG_TYPE(PadV2TestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1673   TEST_WITH_WRONG_TYPE(PadV2TestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1674   TEST_WITH_WRONG_TYPE(PadV2TestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1675   SUCCEED();
1676 }
1677
1678 TEST(QuantizedModelVerifierTest, PadV2_wrong_granularity_NEG)
1679 {
1680   TEST_WITH_WRONG_GRANULARITY(PadV2TestGraph, Type::U8, Granularity::LayerWise);
1681   TEST_WITH_WRONG_GRANULARITY(PadV2TestGraph, Type::U8, Granularity::ChannelWise);
1682   TEST_WITH_WRONG_GRANULARITY(PadV2TestGraph, Type::S16, Granularity::ChannelWise);
1683   SUCCEED();
1684 }
1685
1686 TEST(QuantizedModelVerifierTest, MirrorPad)
1687 {
1688   TEST_WITH_GRAPH(MirrorPadTestGraph, Type::U8, Granularity::LayerWise);
1689   TEST_WITH_GRAPH(MirrorPadTestGraph, Type::U8, Granularity::ChannelWise);
1690   TEST_WITH_GRAPH(MirrorPadTestGraph, Type::S16, Granularity::ChannelWise);
1691   SUCCEED();
1692 }
1693
1694 TEST(QuantizedModelVerifierTest, MirrorPad_wrong_type_NEG)
1695 {
1696   TEST_WITH_WRONG_TYPE(MirrorPadTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1697   TEST_WITH_WRONG_TYPE(MirrorPadTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1698   TEST_WITH_WRONG_TYPE(MirrorPadTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1699   SUCCEED();
1700 }
1701
1702 TEST(QuantizedModelVerifierTest, MirrorPad_wrong_granularity_NEG)
1703 {
1704   TEST_WITH_WRONG_GRANULARITY(MirrorPadTestGraph, Type::U8, Granularity::LayerWise);
1705   TEST_WITH_WRONG_GRANULARITY(MirrorPadTestGraph, Type::U8, Granularity::ChannelWise);
1706   TEST_WITH_WRONG_GRANULARITY(MirrorPadTestGraph, Type::S16, Granularity::ChannelWise);
1707   SUCCEED();
1708 }
1709
1710 TEST(QuantizedModelVerifierTest, Transpose)
1711 {
1712   TEST_WITH_GRAPH(TransposeTestGraph, Type::U8, Granularity::LayerWise);
1713   TEST_WITH_GRAPH(TransposeTestGraph, Type::U8, Granularity::ChannelWise);
1714   TEST_WITH_GRAPH(TransposeTestGraph, Type::S16, Granularity::ChannelWise);
1715   SUCCEED();
1716 }
1717
1718 TEST(QuantizedModelVerifierTest, Transpose_wrong_type_NEG)
1719 {
1720   TEST_WITH_WRONG_TYPE(TransposeTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1721   TEST_WITH_WRONG_TYPE(TransposeTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1722   TEST_WITH_WRONG_TYPE(TransposeTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1723   SUCCEED();
1724 }
1725
1726 TEST(QuantizedModelVerifierTest, Transpose_wrong_granularity_NEG)
1727 {
1728   TEST_WITH_WRONG_GRANULARITY(TransposeTestGraph, Type::U8, Granularity::LayerWise);
1729   TEST_WITH_WRONG_GRANULARITY(TransposeTestGraph, Type::U8, Granularity::ChannelWise);
1730   TEST_WITH_WRONG_GRANULARITY(TransposeTestGraph, Type::S16, Granularity::ChannelWise);
1731   SUCCEED();
1732 }
1733
1734 TEST(QuantizedModelVerifierTest, Floor)
1735 {
1736   TEST_WITH_GRAPH(FloorTestGraph, Type::U8, Granularity::LayerWise);
1737   TEST_WITH_GRAPH(FloorTestGraph, Type::U8, Granularity::ChannelWise);
1738   TEST_WITH_GRAPH(FloorTestGraph, Type::S16, Granularity::ChannelWise);
1739   SUCCEED();
1740 }
1741
1742 TEST(QuantizedModelVerifierTest, Floor_wrong_type_NEG)
1743 {
1744   TEST_WITH_WRONG_TYPE(FloorTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1745   TEST_WITH_WRONG_TYPE(FloorTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1746   TEST_WITH_WRONG_TYPE(FloorTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1747   SUCCEED();
1748 }
1749
1750 TEST(QuantizedModelVerifierTest, Floor_wrong_granularity_NEG)
1751 {
1752   TEST_WITH_WRONG_GRANULARITY(FloorTestGraph, Type::U8, Granularity::LayerWise);
1753   TEST_WITH_WRONG_GRANULARITY(FloorTestGraph, Type::U8, Granularity::ChannelWise);
1754   TEST_WITH_WRONG_GRANULARITY(FloorTestGraph, Type::S16, Granularity::ChannelWise);
1755   SUCCEED();
1756 }
1757
1758 TEST(QuantizedModelVerifierTest, GreaterEqual)
1759 {
1760   TEST_WITH_GRAPH(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::U8,
1761                   Granularity::LayerWise);
1762   TEST_WITH_GRAPH(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::U8,
1763                   Granularity::ChannelWise);
1764   TEST_WITH_GRAPH(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::S16,
1765                   Granularity::ChannelWise);
1766   SUCCEED();
1767 }
1768
1769 TEST(QuantizedModelVerifierTest, GreaterEqual_wrong_type_NEG)
1770 {
1771   TEST_WITH_WRONG_TYPE(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::U8,
1772                        Granularity::LayerWise, Type::U8);
1773   TEST_WITH_WRONG_TYPE(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::U8,
1774                        Granularity::ChannelWise, Type::U8);
1775   TEST_WITH_WRONG_TYPE(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::S16,
1776                        Granularity::ChannelWise, Type::S16);
1777   SUCCEED();
1778 }
1779
1780 TEST(QuantizedModelVerifierTest, GreaterEqual_wrong_granularity_NEG)
1781 {
1782   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::U8,
1783                                      Granularity::LayerWise, g.x());
1784   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::U8,
1785                                      Granularity::ChannelWise, g.x());
1786   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::S16,
1787                                      Granularity::ChannelWise, g.x());
1788
1789   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::U8,
1790                                      Granularity::LayerWise, g.y());
1791   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::U8,
1792                                      Granularity::ChannelWise, g.y());
1793   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreaterEqual>, Type::S16,
1794                                      Granularity::ChannelWise, g.y());
1795   SUCCEED();
1796 }
1797
1798 TEST(QuantizedModelVerifierTest, Greater)
1799 {
1800   TEST_WITH_GRAPH(ComparisonOpTestGraph<luci::CircleGreater>, Type::U8, Granularity::LayerWise);
1801   TEST_WITH_GRAPH(ComparisonOpTestGraph<luci::CircleGreater>, Type::U8, Granularity::ChannelWise);
1802   TEST_WITH_GRAPH(ComparisonOpTestGraph<luci::CircleGreater>, Type::S16, Granularity::ChannelWise);
1803   SUCCEED();
1804 }
1805
1806 TEST(QuantizedModelVerifierTest, Greater_wrong_type_NEG)
1807 {
1808   TEST_WITH_WRONG_TYPE(ComparisonOpTestGraph<luci::CircleGreater>, Type::U8, Granularity::LayerWise,
1809                        Type::U8);
1810   TEST_WITH_WRONG_TYPE(ComparisonOpTestGraph<luci::CircleGreater>, Type::U8,
1811                        Granularity::ChannelWise, Type::U8);
1812   TEST_WITH_WRONG_TYPE(ComparisonOpTestGraph<luci::CircleGreater>, Type::S16,
1813                        Granularity::ChannelWise, Type::S16);
1814   SUCCEED();
1815 }
1816
1817 TEST(QuantizedModelVerifierTest, Greater_wrong_granularity_NEG)
1818 {
1819   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreater>, Type::U8,
1820                                      Granularity::LayerWise, g.x());
1821   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreater>, Type::U8,
1822                                      Granularity::ChannelWise, g.x());
1823   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreater>, Type::S16,
1824                                      Granularity::ChannelWise, g.x());
1825
1826   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreater>, Type::U8,
1827                                      Granularity::LayerWise, g.y());
1828   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreater>, Type::U8,
1829                                      Granularity::ChannelWise, g.y());
1830   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleGreater>, Type::S16,
1831                                      Granularity::ChannelWise, g.y());
1832   SUCCEED();
1833 }
1834
1835 TEST(QuantizedModelVerifierTest, NotEqual)
1836 {
1837   TEST_WITH_GRAPH(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::U8, Granularity::LayerWise);
1838   TEST_WITH_GRAPH(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::U8, Granularity::ChannelWise);
1839   TEST_WITH_GRAPH(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::S16, Granularity::ChannelWise);
1840   SUCCEED();
1841 }
1842
1843 TEST(QuantizedModelVerifierTest, NotEqual_wrong_type_NEG)
1844 {
1845   TEST_WITH_WRONG_TYPE(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::U8,
1846                        Granularity::LayerWise, Type::U8);
1847   TEST_WITH_WRONG_TYPE(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::U8,
1848                        Granularity::ChannelWise, Type::U8);
1849   TEST_WITH_WRONG_TYPE(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::S16,
1850                        Granularity::ChannelWise, Type::S16);
1851   SUCCEED();
1852 }
1853
1854 TEST(QuantizedModelVerifierTest, NotEqual_wrong_granularity_NEG)
1855 {
1856   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::U8,
1857                                      Granularity::LayerWise, g.x());
1858   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::U8,
1859                                      Granularity::ChannelWise, g.x());
1860   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::S16,
1861                                      Granularity::ChannelWise, g.x());
1862
1863   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::U8,
1864                                      Granularity::LayerWise, g.y());
1865   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::U8,
1866                                      Granularity::ChannelWise, g.y());
1867   TEST_WITH_WRONG_GRANULARITY_TARGET(ComparisonOpTestGraph<luci::CircleNotEqual>, Type::S16,
1868                                      Granularity::ChannelWise, g.y());
1869   SUCCEED();
1870 }
1871
1872 TEST(QuantizedModelVerifierTest, Div)
1873 {
1874   TEST_WITH_GRAPH(DivTestGraph, Type::U8, Granularity::LayerWise);
1875   TEST_WITH_GRAPH(DivTestGraph, Type::U8, Granularity::ChannelWise);
1876   TEST_WITH_GRAPH(DivTestGraph, Type::S16, Granularity::ChannelWise);
1877   SUCCEED();
1878 }
1879
1880 TEST(QuantizedModelVerifierTest, Div_wrong_type_NEG)
1881 {
1882   TEST_WITH_WRONG_TYPE(DivTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1883   TEST_WITH_WRONG_TYPE(DivTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1884   TEST_WITH_WRONG_TYPE(DivTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1885   SUCCEED();
1886 }
1887
1888 TEST(QuantizedModelVerifierTest, Div_wrong_granularity_NEG)
1889 {
1890   TEST_WITH_WRONG_GRANULARITY_TARGET(DivTestGraph, Type::U8, Granularity::LayerWise, g.x());
1891   TEST_WITH_WRONG_GRANULARITY_TARGET(DivTestGraph, Type::U8, Granularity::ChannelWise, g.x());
1892   TEST_WITH_WRONG_GRANULARITY_TARGET(DivTestGraph, Type::S16, Granularity::ChannelWise, g.x());
1893
1894   TEST_WITH_WRONG_GRANULARITY_TARGET(DivTestGraph, Type::U8, Granularity::LayerWise, g.y());
1895   TEST_WITH_WRONG_GRANULARITY_TARGET(DivTestGraph, Type::U8, Granularity::ChannelWise, g.y());
1896   TEST_WITH_WRONG_GRANULARITY_TARGET(DivTestGraph, Type::S16, Granularity::ChannelWise, g.y());
1897   SUCCEED();
1898 }
1899
1900 TEST(QuantizedModelVerifierTest, FloorDiv)
1901 {
1902   TEST_WITH_GRAPH(FloorDivTestGraph, Type::U8, Granularity::LayerWise);
1903   TEST_WITH_GRAPH(FloorDivTestGraph, Type::U8, Granularity::ChannelWise);
1904   TEST_WITH_GRAPH(FloorDivTestGraph, Type::S16, Granularity::ChannelWise);
1905   SUCCEED();
1906 }
1907
1908 TEST(QuantizedModelVerifierTest, FloorDiv_wrong_type_NEG)
1909 {
1910   TEST_WITH_WRONG_TYPE(FloorDivTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1911   TEST_WITH_WRONG_TYPE(FloorDivTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1912   TEST_WITH_WRONG_TYPE(FloorDivTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1913   SUCCEED();
1914 }
1915
1916 TEST(QuantizedModelVerifierTest, FloorDiv_wrong_granularity_NEG)
1917 {
1918   TEST_WITH_WRONG_GRANULARITY_TARGET(FloorDivTestGraph, Type::U8, Granularity::LayerWise, g.x());
1919   TEST_WITH_WRONG_GRANULARITY_TARGET(FloorDivTestGraph, Type::U8, Granularity::ChannelWise, g.x());
1920   TEST_WITH_WRONG_GRANULARITY_TARGET(FloorDivTestGraph, Type::S16, Granularity::ChannelWise, g.x());
1921
1922   TEST_WITH_WRONG_GRANULARITY_TARGET(FloorDivTestGraph, Type::U8, Granularity::LayerWise, g.y());
1923   TEST_WITH_WRONG_GRANULARITY_TARGET(FloorDivTestGraph, Type::U8, Granularity::ChannelWise, g.y());
1924   TEST_WITH_WRONG_GRANULARITY_TARGET(FloorDivTestGraph, Type::S16, Granularity::ChannelWise, g.y());
1925   SUCCEED();
1926 }
1927
1928 TEST(QuantizedModelVerifierTest, Rsqrt)
1929 {
1930   TEST_WITH_GRAPH(RsqrtTestGraph, Type::U8, Granularity::LayerWise);
1931   TEST_WITH_GRAPH(RsqrtTestGraph, Type::U8, Granularity::ChannelWise);
1932   TEST_WITH_GRAPH(RsqrtTestGraph, Type::S16, Granularity::ChannelWise);
1933   SUCCEED();
1934 }
1935
1936 TEST(QuantizedModelVerifierTest, Rsqrt_wrong_type_NEG)
1937 {
1938   TEST_WITH_WRONG_TYPE(RsqrtTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1939   TEST_WITH_WRONG_TYPE(RsqrtTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1940   TEST_WITH_WRONG_TYPE(RsqrtTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1941   SUCCEED();
1942 }
1943
1944 TEST(QuantizedModelVerifierTest, Rsqrt_wrong_granularity_NEG)
1945 {
1946   TEST_WITH_WRONG_GRANULARITY(RsqrtTestGraph, Type::U8, Granularity::LayerWise);
1947   TEST_WITH_WRONG_GRANULARITY(RsqrtTestGraph, Type::U8, Granularity::ChannelWise);
1948   TEST_WITH_WRONG_GRANULARITY(RsqrtTestGraph, Type::S16, Granularity::ChannelWise);
1949   SUCCEED();
1950 }
1951
1952 TEST(QuantizedModelVerifierTest, Sqrt)
1953 {
1954   TEST_WITH_GRAPH(SqrtTestGraph, Type::U8, Granularity::LayerWise);
1955   TEST_WITH_GRAPH(SqrtTestGraph, Type::U8, Granularity::ChannelWise);
1956   TEST_WITH_GRAPH(SqrtTestGraph, Type::S16, Granularity::ChannelWise);
1957   SUCCEED();
1958 }
1959
1960 TEST(QuantizedModelVerifierTest, Sqrt_wrong_type_NEG)
1961 {
1962   TEST_WITH_WRONG_TYPE(SqrtTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1963   TEST_WITH_WRONG_TYPE(SqrtTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1964   TEST_WITH_WRONG_TYPE(SqrtTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1965   SUCCEED();
1966 }
1967
1968 TEST(QuantizedModelVerifierTest, Sqrt_wrong_granularity_NEG)
1969 {
1970   TEST_WITH_WRONG_GRANULARITY(SqrtTestGraph, Type::U8, Granularity::LayerWise);
1971   TEST_WITH_WRONG_GRANULARITY(SqrtTestGraph, Type::U8, Granularity::ChannelWise);
1972   TEST_WITH_WRONG_GRANULARITY(SqrtTestGraph, Type::S16, Granularity::ChannelWise);
1973   SUCCEED();
1974 }
1975
1976 TEST(QuantizedModelVerifierTest, Elu)
1977 {
1978   TEST_WITH_GRAPH(EluTestGraph, Type::U8, Granularity::LayerWise);
1979   TEST_WITH_GRAPH(EluTestGraph, Type::U8, Granularity::ChannelWise);
1980   TEST_WITH_GRAPH(EluTestGraph, Type::S16, Granularity::ChannelWise);
1981   SUCCEED();
1982 }
1983
1984 TEST(QuantizedModelVerifierTest, Elu_wrong_type_NEG)
1985 {
1986   TEST_WITH_WRONG_TYPE(EluTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
1987   TEST_WITH_WRONG_TYPE(EluTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
1988   TEST_WITH_WRONG_TYPE(EluTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
1989   SUCCEED();
1990 }
1991
1992 TEST(QuantizedModelVerifierTest, Elu_wrong_granularity_NEG)
1993 {
1994   TEST_WITH_WRONG_GRANULARITY(EluTestGraph, Type::U8, Granularity::LayerWise);
1995   TEST_WITH_WRONG_GRANULARITY(EluTestGraph, Type::U8, Granularity::ChannelWise);
1996   TEST_WITH_WRONG_GRANULARITY(EluTestGraph, Type::S16, Granularity::ChannelWise);
1997   SUCCEED();
1998 }
1999
2000 TEST(QuantizedModelVerifierTest, Pow)
2001 {
2002   TEST_WITH_GRAPH(PowTestGraph, Type::U8, Granularity::LayerWise);
2003   TEST_WITH_GRAPH(PowTestGraph, Type::U8, Granularity::ChannelWise);
2004   TEST_WITH_GRAPH(PowTestGraph, Type::S16, Granularity::ChannelWise);
2005   SUCCEED();
2006 }
2007
2008 TEST(QuantizedModelVerifierTest, Pow_wrong_type_NEG)
2009 {
2010   TEST_WITH_WRONG_TYPE(PowTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
2011   TEST_WITH_WRONG_TYPE(PowTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
2012   TEST_WITH_WRONG_TYPE(PowTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
2013   SUCCEED();
2014 }
2015
2016 TEST(QuantizedModelVerifierTest, Pow_wrong_granularity_NEG)
2017 {
2018   TEST_WITH_WRONG_GRANULARITY_TARGET(PowTestGraph, Type::U8, Granularity::LayerWise, g.x());
2019   TEST_WITH_WRONG_GRANULARITY_TARGET(PowTestGraph, Type::U8, Granularity::ChannelWise, g.x());
2020   TEST_WITH_WRONG_GRANULARITY_TARGET(PowTestGraph, Type::S16, Granularity::ChannelWise, g.x());
2021
2022   TEST_WITH_WRONG_GRANULARITY_TARGET(PowTestGraph, Type::U8, Granularity::LayerWise, g.y());
2023   TEST_WITH_WRONG_GRANULARITY_TARGET(PowTestGraph, Type::U8, Granularity::ChannelWise, g.y());
2024   TEST_WITH_WRONG_GRANULARITY_TARGET(PowTestGraph, Type::S16, Granularity::ChannelWise, g.y());
2025   SUCCEED();
2026 }
2027
2028 TEST(QuantizedModelVerifierTest, ResizeBilinear)
2029 {
2030   TEST_WITH_GRAPH(ResizeBilinearTestGraph, Type::U8, Granularity::LayerWise);
2031   TEST_WITH_GRAPH(ResizeBilinearTestGraph, Type::U8, Granularity::ChannelWise);
2032   TEST_WITH_GRAPH(ResizeBilinearTestGraph, Type::S16, Granularity::ChannelWise);
2033   SUCCEED();
2034 }
2035
2036 TEST(QuantizedModelVerifierTest, ResizeBilinear_wrong_type_NEG)
2037 {
2038   TEST_WITH_WRONG_TYPE(ResizeBilinearTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
2039   TEST_WITH_WRONG_TYPE(ResizeBilinearTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
2040   TEST_WITH_WRONG_TYPE(ResizeBilinearTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
2041   SUCCEED();
2042 }
2043
2044 TEST(QuantizedModelVerifierTest, ResizeBilinear_wrong_granularity_NEG)
2045 {
2046   TEST_WITH_WRONG_GRANULARITY(ResizeBilinearTestGraph, Type::U8, Granularity::LayerWise);
2047   TEST_WITH_WRONG_GRANULARITY(ResizeBilinearTestGraph, Type::U8, Granularity::ChannelWise);
2048   TEST_WITH_WRONG_GRANULARITY(ResizeBilinearTestGraph, Type::S16, Granularity::ChannelWise);
2049   SUCCEED();
2050 }
2051
2052 TEST(QuantizedModelVerifierTest, ResizeNearestNeighbor)
2053 {
2054   TEST_WITH_GRAPH(ResizeNearestNeighborTestGraph, Type::U8, Granularity::LayerWise);
2055   TEST_WITH_GRAPH(ResizeNearestNeighborTestGraph, Type::U8, Granularity::ChannelWise);
2056   TEST_WITH_GRAPH(ResizeNearestNeighborTestGraph, Type::S16, Granularity::ChannelWise);
2057   SUCCEED();
2058 }
2059
2060 TEST(QuantizedModelVerifierTest, ResizeNearestNeighbor_wrong_type_NEG)
2061 {
2062   TEST_WITH_WRONG_TYPE(ResizeNearestNeighborTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
2063   TEST_WITH_WRONG_TYPE(ResizeNearestNeighborTestGraph, Type::U8, Granularity::ChannelWise,
2064                        Type::S16);
2065   TEST_WITH_WRONG_TYPE(ResizeNearestNeighborTestGraph, Type::S16, Granularity::ChannelWise,
2066                        Type::U8);
2067   SUCCEED();
2068 }
2069
2070 TEST(QuantizedModelVerifierTest, ResizeNearestNeighbor_wrong_granularity_NEG)
2071 {
2072   TEST_WITH_WRONG_GRANULARITY(ResizeNearestNeighborTestGraph, Type::U8, Granularity::LayerWise);
2073   TEST_WITH_WRONG_GRANULARITY(ResizeNearestNeighborTestGraph, Type::U8, Granularity::ChannelWise);
2074   TEST_WITH_WRONG_GRANULARITY(ResizeNearestNeighborTestGraph, Type::S16, Granularity::ChannelWise);
2075   SUCCEED();
2076 }
2077
2078 TEST(QuantizedModelVerifierTest, Unpack)
2079 {
2080   TEST_WITH_GRAPH(UnpackTestGraph, Type::U8, Granularity::LayerWise);
2081   TEST_WITH_GRAPH(UnpackTestGraph, Type::U8, Granularity::ChannelWise);
2082   TEST_WITH_GRAPH(UnpackTestGraph, Type::S16, Granularity::ChannelWise);
2083   SUCCEED();
2084 }
2085
2086 TEST(QuantizedModelVerifierTest, Unpack_wrong_type_NEG)
2087 {
2088   TEST_WITH_WRONG_TYPE(UnpackTestGraph, Type::U8, Granularity::LayerWise, Type::S16);
2089   TEST_WITH_WRONG_TYPE(UnpackTestGraph, Type::U8, Granularity::ChannelWise, Type::S16);
2090   TEST_WITH_WRONG_TYPE(UnpackTestGraph, Type::S16, Granularity::ChannelWise, Type::U8);
2091   SUCCEED();
2092 }
2093
2094 TEST(QuantizedModelVerifierTest, Unpack_wrong_granularity_NEG)
2095 {
2096   TEST_WITH_WRONG_GRANULARITY(UnpackTestGraph, Type::U8, Granularity::LayerWise);
2097   TEST_WITH_WRONG_GRANULARITY(UnpackTestGraph, Type::U8, Granularity::ChannelWise);
2098   TEST_WITH_WRONG_GRANULARITY(UnpackTestGraph, Type::S16, Granularity::ChannelWise);
2099   SUCCEED();
2100 }
2101
2102 #undef TEST_WITH_GRAPH
2103 #undef TEST_WITH_WRONG_TYPE
2104 #undef TEST_WITH_WRONG_GRANULARITY