Imported Upstream version 1.25.0
[platform/core/ml/nnfw.git] / compiler / circledump / src / OpPrinter.cpp
1 /*
2  * Copyright (c) 2020 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 "OpPrinter.h"
18
19 #include <mio_circle/Helper.h>
20
21 #include <memory>
22
23 #include <flatbuffers/flexbuffers.h>
24
25 using std::make_unique;
26
27 namespace circledump
28 {
29
30 // TODO move to some header
31 std::ostream &operator<<(std::ostream &os, const std::vector<int32_t> &vect);
32
33 // TODO Re-arrange in alphabetical order
34
35 class AddPrinter : public OpPrinter
36 {
37 public:
38   void options(const circle::Operator *op, std::ostream &os) const override
39   {
40     if (auto *params = op->builtin_options_as_AddOptions())
41     {
42       os << "    ";
43       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
44          << ") ";
45       os << std::endl;
46     }
47   }
48 };
49
50 class ArgMaxPrinter : public OpPrinter
51 {
52 public:
53   void options(const circle::Operator *op, std::ostream &os) const override
54   {
55     if (auto *params = op->builtin_options_as_ArgMaxOptions())
56     {
57       os << "    ";
58       os << "OutputType(" << EnumNameTensorType(params->output_type()) << ") ";
59       os << std::endl;
60     }
61   }
62 };
63
64 class ArgMinPrinter : public OpPrinter
65 {
66 public:
67   void options(const circle::Operator *op, std::ostream &os) const override
68   {
69     if (auto *params = op->builtin_options_as_ArgMinOptions())
70     {
71       os << "    ";
72       os << "OutputType(" << EnumNameTensorType(params->output_type()) << ") ";
73       os << std::endl;
74     }
75   }
76 };
77
78 class BatchMatMulPrinter : public OpPrinter
79 {
80 public:
81   void options(const circle::Operator *op, std::ostream &os) const override
82   {
83     if (auto *params = op->builtin_options_as_BatchMatMulOptions())
84     {
85       os << "    ";
86       os << std::boolalpha;
87       os << "adjoint_lhs(" << params->adjoint_lhs() << ") ";
88       os << "adjoint_rhs(" << params->adjoint_rhs() << ") ";
89       os << std::noboolalpha;
90       os << std::endl;
91     }
92   }
93 };
94
95 class BidirectionalSequenceLSTMPrinter : public OpPrinter
96 {
97 public:
98   void options(const circle::Operator *op, std::ostream &os) const override
99   {
100     if (auto *params = op->builtin_options_as_BidirectionalSequenceLSTMOptions())
101     {
102       os << "    ";
103       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
104          << ") ";
105       os << "cell_clip(" << params->cell_clip() << ") ";
106       os << "proj_clip(" << params->proj_clip() << ") ";
107       os << "time_major(" << params->time_major() << ") ";
108       os << "asymmetric_quantize_inputs(" << params->asymmetric_quantize_inputs() << ") ";
109       os << "merge_outputs(" << params->merge_outputs() << ") ";
110       os << std::endl;
111     }
112   }
113 };
114
115 class CastPrinter : public OpPrinter
116 {
117 public:
118   void options(const circle::Operator *op, std::ostream &os) const override
119   {
120     if (auto cast_params = op->builtin_options_as_CastOptions())
121     {
122       os << "    ";
123       os << "in_data_type(" << circle::EnumNameTensorType(cast_params->in_data_type()) << ") ";
124       os << "out_data_type(" << circle::EnumNameTensorType(cast_params->out_data_type()) << ") ";
125       os << std::endl;
126     }
127   }
128 };
129
130 class Conv2DPrinter : public OpPrinter
131 {
132 public:
133   void options(const circle::Operator *op, std::ostream &os) const override
134   {
135     if (auto conv_params = op->builtin_options_as_Conv2DOptions())
136     {
137       os << "    ";
138       os << "Padding(" << conv_params->padding() << ") ";
139       os << "Stride.W(" << conv_params->stride_w() << ") ";
140       os << "Stride.H(" << conv_params->stride_h() << ") ";
141       os << "Dilation.W(" << conv_params->dilation_w_factor() << ") ";
142       os << "Dilation.H(" << conv_params->dilation_h_factor() << ") ";
143       os << "Activation("
144          << EnumNameActivationFunctionType(conv_params->fused_activation_function()) << ")";
145       os << std::endl;
146     }
147   }
148 };
149
150 class DepthToSpacePrinter : public OpPrinter
151 {
152 public:
153   void options(const circle::Operator *op, std::ostream &os) const override
154   {
155     if (auto *std_params = op->builtin_options_as_DepthToSpaceOptions())
156     {
157       os << "    ";
158       os << "BlockSize(" << std_params->block_size() << ")";
159       os << std::endl;
160     }
161   }
162 };
163
164 class DivPrinter : public OpPrinter
165 {
166 public:
167   void options(const circle::Operator *op, std::ostream &os) const override
168   {
169     if (auto *params = op->builtin_options_as_DivOptions())
170     {
171       os << "    ";
172       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
173          << ") ";
174       os << std::endl;
175     }
176   }
177 };
178
179 class Pool2DPrinter : public OpPrinter
180 {
181 public:
182   void options(const circle::Operator *op, std::ostream &os) const override
183   {
184     if (auto pool_params = op->builtin_options_as_Pool2DOptions())
185     {
186       os << "    ";
187       os << "Padding(" << pool_params->padding() << ") ";
188       os << "Stride.W(" << pool_params->stride_w() << ") ";
189       os << "Stride.H(" << pool_params->stride_h() << ") ";
190       os << "Filter.W(" << pool_params->filter_width() << ") ";
191       os << "Filter.H(" << pool_params->filter_height() << ") ";
192       os << "Activation("
193          << EnumNameActivationFunctionType(pool_params->fused_activation_function()) << ")";
194       os << std::endl;
195     }
196   }
197 };
198
199 class ConcatenationPrinter : public OpPrinter
200 {
201 public:
202   void options(const circle::Operator *op, std::ostream &os) const override
203   {
204     if (auto *concatenation_params = op->builtin_options_as_ConcatenationOptions())
205     {
206       os << "    ";
207       os << "Activation("
208          << EnumNameActivationFunctionType(concatenation_params->fused_activation_function())
209          << ") ";
210       os << "Axis(" << concatenation_params->axis() << ")";
211       os << std::endl;
212     }
213   }
214 };
215
216 class ReducerPrinter : public OpPrinter
217 {
218 public:
219   void options(const circle::Operator *op, std::ostream &os) const override
220   {
221     if (auto reducer_params = op->builtin_options_as_ReducerOptions())
222     {
223       os << "    ";
224       os << "keep_dims(" << reducer_params->keep_dims() << ") ";
225       os << std::endl;
226     }
227   }
228 };
229
230 class ReshapePrinter : public OpPrinter
231 {
232 public:
233   void options(const circle::Operator *op, std::ostream &os) const override
234   {
235     if (auto *reshape_params = op->builtin_options_as_ReshapeOptions())
236     {
237       auto new_shape = mio::circle::as_index_vector(reshape_params->new_shape());
238       os << "    ";
239       os << "NewShape(" << new_shape << ")";
240       os << std::endl;
241     }
242   }
243 };
244
245 class ResizeBilinearPrinter : public OpPrinter
246 {
247 public:
248   void options(const circle::Operator *op, std::ostream &os) const override
249   {
250     if (auto *resize_params = op->builtin_options_as_ResizeBilinearOptions())
251     {
252       os << "    ";
253       os << std::boolalpha;
254       os << "align_corners(" << resize_params->align_corners() << ")";
255       os << "half_pixel_centers(" << resize_params->half_pixel_centers() << ")";
256       os << std::noboolalpha;
257       os << std::endl;
258     }
259   }
260 };
261
262 class ResizeNearestNeighborPrinter : public OpPrinter
263 {
264 public:
265   void options(const circle::Operator *op, std::ostream &os) const override
266   {
267     if (auto *resize_params = op->builtin_options_as_ResizeNearestNeighborOptions())
268     {
269       os << "    ";
270       os << std::boolalpha;
271       os << "align_corners(" << resize_params->align_corners() << ")";
272       os << std::noboolalpha;
273       os << std::endl;
274     }
275   }
276 };
277
278 class ReverseSequencePrinter : public OpPrinter
279 {
280 public:
281   void options(const circle::Operator *op, std::ostream &os) const override
282   {
283     if (auto *params = op->builtin_options_as_ReverseSequenceOptions())
284     {
285       os << "    ";
286       os << "seq_dim(" << params->seq_dim() << ") ";
287       os << "batch_dim(" << params->batch_dim() << ") ";
288       os << std::endl;
289     }
290   }
291 };
292
293 class DepthwiseConv2DPrinter : public OpPrinter
294 {
295 public:
296   void options(const circle::Operator *op, std::ostream &os) const override
297   {
298     if (auto conv_params = op->builtin_options_as_DepthwiseConv2DOptions())
299     {
300       os << "    ";
301       os << "Padding(" << conv_params->padding() << ") ";
302       os << "Stride.W(" << conv_params->stride_w() << ") ";
303       os << "Stride.H(" << conv_params->stride_h() << ") ";
304       os << "DepthMultiplier(" << conv_params->depth_multiplier() << ") ";
305       os << "Dilation.W(" << conv_params->dilation_w_factor() << ") ";
306       os << "Dilation.H(" << conv_params->dilation_h_factor() << ") ";
307       os << "Activation("
308          << EnumNameActivationFunctionType(conv_params->fused_activation_function()) << ") ";
309       os << std::endl;
310     }
311   }
312 };
313
314 class FakeQuantPrinter : public OpPrinter
315 {
316 public:
317   void options(const circle::Operator *op, std::ostream &os) const override
318   {
319     if (auto *params = op->builtin_options_as_FakeQuantOptions())
320     {
321       os << "    ";
322       os << "Min(" << params->min() << ") ";
323       os << "Max(" << params->max() << ") ";
324       os << "NumBits(" << params->num_bits() << ") ";
325       os << std::boolalpha;
326       os << "NarrowRange(" << params->narrow_range() << ") ";
327       os << std::noboolalpha;
328       os << std::endl;
329     }
330   }
331 };
332
333 class FullyConnectedPrinter : public OpPrinter
334 {
335 public:
336   void options(const circle::Operator *op, std::ostream &os) const override
337   {
338     if (auto *params = op->builtin_options_as_FullyConnectedOptions())
339     {
340       os << "    ";
341       os << "WeightFormat(" << EnumNameFullyConnectedOptionsWeightsFormat(params->weights_format())
342          << ") ";
343       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
344          << ") ";
345       os << "keep_num_dims(" << params->keep_num_dims() << ") ";
346
347       os << std::endl;
348     }
349   }
350 };
351
352 class GatherPrinter : public OpPrinter
353 {
354 public:
355   void options(const circle::Operator *op, std::ostream &os) const override
356   {
357     if (auto *params = op->builtin_options_as_GatherOptions())
358     {
359       os << "    ";
360       os << "Axis(" << params->axis() << ") ";
361
362       os << std::endl;
363     }
364   }
365 };
366
367 class GeluPrinter : public OpPrinter
368 {
369 public:
370   void options(const circle::Operator *op, std::ostream &os) const override
371   {
372     if (auto *params = op->builtin_options_as_GeluOptions())
373     {
374       os << "    ";
375       os << std::boolalpha;
376       os << "approximate(" << params->approximate() << ") ";
377       os << std::noboolalpha;
378       os << std::endl;
379     }
380   }
381 };
382
383 class IfPrinter : public OpPrinter
384 {
385 public:
386   void options(const circle::Operator *op, std::ostream &os) const override
387   {
388     if (auto *params = op->builtin_options_as_IfOptions())
389     {
390       os << "    ";
391       os << "then_subgraph_index(" << params->then_subgraph_index() << ") ";
392       os << "else_subgraph_index(" << params->else_subgraph_index() << ") ";
393       os << std::endl;
394     }
395   }
396 };
397
398 class L2NormPrinter : public OpPrinter
399 {
400 public:
401   void options(const circle::Operator *op, std::ostream &os) const override
402   {
403     if (auto *params = op->builtin_options_as_L2NormOptions())
404     {
405       os << "    ";
406       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
407          << ") ";
408       os << std::endl;
409     }
410   }
411 };
412
413 class LeakyReluPrinter : public OpPrinter
414 {
415 public:
416   void options(const circle::Operator *op, std::ostream &os) const override
417   {
418     if (auto *params = op->builtin_options_as_LeakyReluOptions())
419     {
420       os << "    ";
421       os << "alpha(" << params->alpha() << ") ";
422     }
423   }
424 };
425
426 class LocalResponseNormalizationPrinter : public OpPrinter
427 {
428 public:
429   void options(const circle::Operator *op, std::ostream &os) const override
430   {
431     if (auto *params = op->builtin_options_as_LocalResponseNormalizationOptions())
432     {
433       os << "    ";
434       os << "radius(" << params->radius() << ") ";
435       os << "bias(" << params->bias() << ") ";
436       os << "alpha(" << params->alpha() << ") ";
437       os << "beta(" << params->beta() << ") ";
438       os << std::endl;
439     }
440   }
441 };
442
443 class MirrorPadPrinter : public OpPrinter
444 {
445 public:
446   void options(const circle::Operator *op, std::ostream &os) const override
447   {
448     if (auto *params = op->builtin_options_as_MirrorPadOptions())
449     {
450       os << "    ";
451       os << "mode(" << EnumNameMirrorPadMode(params->mode()) << ") ";
452       os << std::endl;
453     }
454   }
455 };
456
457 class MulPrinter : public OpPrinter
458 {
459 public:
460   void options(const circle::Operator *op, std::ostream &os) const override
461   {
462     if (auto *params = op->builtin_options_as_MulOptions())
463     {
464       os << "    ";
465       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
466          << ") ";
467       os << std::endl;
468     }
469   }
470 };
471
472 class OneHotPrinter : public OpPrinter
473 {
474 public:
475   void options(const circle::Operator *op, std::ostream &os) const override
476   {
477     if (auto *params = op->builtin_options_as_OneHotOptions())
478     {
479       os << "    ";
480       os << "Axis(" << params->axis() << ") ";
481
482       os << std::endl;
483     }
484   }
485 };
486
487 class PackPrinter : public OpPrinter
488 {
489 public:
490   void options(const circle::Operator *op, std::ostream &os) const override
491   {
492     if (auto *params = op->builtin_options_as_PackOptions())
493     {
494       os << "    ";
495       os << "ValuesCount(" << params->values_count() << ") ";
496       os << "Axis(" << params->axis() << ") ";
497       os << std::endl;
498     }
499   }
500 };
501
502 class ShapePrinter : public OpPrinter
503 {
504 public:
505   void options(const circle::Operator *op, std::ostream &os) const override
506   {
507     if (auto *params = op->builtin_options_as_ShapeOptions())
508     {
509       os << "    ";
510       os << "out_type(" << EnumNameTensorType(params->out_type()) << ") ";
511       os << std::endl;
512     }
513   }
514 };
515
516 class SoftmaxPrinter : public OpPrinter
517 {
518 public:
519   void options(const circle::Operator *op, std::ostream &os) const override
520   {
521     if (auto *softmax_params = op->builtin_options_as_SoftmaxOptions())
522     {
523       os << "    ";
524       os << "Beta(" << softmax_params->beta() << ")";
525       os << std::endl;
526     }
527   }
528 };
529
530 class SpaceToDepthPrinter : public OpPrinter
531 {
532 public:
533   void options(const circle::Operator *op, std::ostream &os) const override
534   {
535     if (auto *std_params = op->builtin_options_as_SpaceToDepthOptions())
536     {
537       os << "    ";
538       os << "BlockSize(" << std_params->block_size() << ")";
539       os << std::endl;
540     }
541   }
542 };
543
544 class SparseToDensePrinter : public OpPrinter
545 {
546 public:
547   void options(const circle::Operator *op, std::ostream &os) const override
548   {
549     if (auto *std_params = op->builtin_options_as_SparseToDenseOptions())
550     {
551       os << "    ";
552       os << "ValidateIndices(" << std_params->validate_indices() << ")";
553       os << std::endl;
554     }
555   }
556 };
557
558 class SplitPrinter : public OpPrinter
559 {
560 public:
561   void options(const circle::Operator *op, std::ostream &os) const override
562   {
563     if (auto *params = op->builtin_options_as_SplitOptions())
564     {
565       os << "    ";
566       os << "num_splits(" << params->num_splits() << ") ";
567       os << std::endl;
568     }
569   }
570 };
571
572 class SplitVPrinter : public OpPrinter
573 {
574 public:
575   void options(const circle::Operator *op, std::ostream &os) const override
576   {
577     if (auto *params = op->builtin_options_as_SplitVOptions())
578     {
579       os << "    ";
580       os << "num_splits(" << params->num_splits() << ") ";
581       os << std::endl;
582     }
583   }
584 };
585
586 class SqueezePrinter : public OpPrinter
587 {
588 public:
589   void options(const circle::Operator *op, std::ostream &os) const override
590   {
591     if (auto *params = op->builtin_options_as_SqueezeOptions())
592     {
593       os << "    ";
594       os << "SqueezeDims(";
595       for (int i = 0; i < params->squeeze_dims()->size(); ++i)
596       {
597         if (i != 0)
598           os << ", ";
599         os << params->squeeze_dims()->Get(i);
600       }
601       os << ")";
602       os << std::endl;
603     }
604   }
605 };
606
607 class StridedSlicePrinter : public OpPrinter
608 {
609 public:
610   void options(const circle::Operator *op, std::ostream &os) const override
611   {
612     if (auto *strided_slice_params = op->builtin_options_as_StridedSliceOptions())
613     {
614       os << "    ";
615       os << "begin_mask(" << strided_slice_params->begin_mask() << ") ";
616       os << "end_mask(" << strided_slice_params->end_mask() << ") ";
617       os << "ellipsis_mask(" << strided_slice_params->ellipsis_mask() << ") ";
618       os << "new_axis_mask(" << strided_slice_params->new_axis_mask() << ") ";
619       os << "shrink_axis_mask(" << strided_slice_params->shrink_axis_mask() << ") ";
620       os << std::endl;
621     }
622   }
623 };
624
625 class SubPrinter : public OpPrinter
626 {
627 public:
628   void options(const circle::Operator *op, std::ostream &os) const override
629   {
630     if (auto *params = op->builtin_options_as_SubOptions())
631     {
632       os << "    ";
633       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
634          << ") ";
635       os << std::endl;
636     }
637   }
638 };
639
640 class SVDFPrinter : public OpPrinter
641 {
642 public:
643   void options(const circle::Operator *op, std::ostream &os) const override
644   {
645     if (auto *params = op->builtin_options_as_SVDFOptions())
646     {
647       os << "    ";
648       os << "rank(" << params->rank() << ") ";
649       os << "activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
650          << ") ";
651       os << "asymmetric_quantize_inputs(" << params->asymmetric_quantize_inputs() << ") ";
652       os << std::endl;
653     }
654   }
655 };
656
657 class TransposeConvPrinter : public OpPrinter
658 {
659 public:
660   void options(const circle::Operator *op, std::ostream &os) const override
661   {
662     if (auto params = op->builtin_options_as_TransposeConvOptions())
663     {
664       os << "    ";
665       os << "Padding(" << params->padding() << ") ";
666       os << "Stride.W(" << params->stride_w() << ") ";
667       os << "Stride.H(" << params->stride_h() << ") ";
668       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
669          << ") ";
670       os << std::endl;
671     }
672   }
673 };
674
675 class UnidirectionalSequenceLSTMPrinter : public OpPrinter
676 {
677 public:
678   void options(const circle::Operator *op, std::ostream &os) const override
679   {
680     if (auto *params = op->builtin_options_as_UnidirectionalSequenceLSTMOptions())
681     {
682       os << "    ";
683       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
684          << ") ";
685       os << "cell_clip(" << params->cell_clip() << ") ";
686       os << "proj_clip(" << params->proj_clip() << ") ";
687       os << "time_major(" << params->time_major() << ") ";
688       os << "asymmetric_quantize_inputs(" << params->asymmetric_quantize_inputs() << ") ";
689       os << std::endl;
690     }
691   }
692 };
693
694 class UniquePrinter : public OpPrinter
695 {
696 public:
697   void options(const circle::Operator *op, std::ostream &os) const override
698   {
699     if (auto *params = op->builtin_options_as_UniqueOptions())
700     {
701       os << "    ";
702       os << "idx_out_type(" << EnumNameTensorType(params->idx_out_type()) << ") ";
703       os << std::endl;
704     }
705   }
706 };
707
708 class WhilePrinter : public OpPrinter
709 {
710 public:
711   void options(const circle::Operator *op, std::ostream &os) const override
712   {
713     if (auto *params = op->builtin_options_as_WhileOptions())
714     {
715       os << "    ";
716       os << "cond_subgraph_index(" << params->cond_subgraph_index() << ") ";
717       os << "body_subgraph_index(" << params->body_subgraph_index() << ") ";
718       os << std::endl;
719     }
720   }
721 };
722
723 class CustomOpPrinter : public OpPrinter
724 {
725 public:
726   void options(const circle::Operator *op, std::ostream &os) const override
727   {
728     if (op->custom_options_format() != circle::CustomOptionsFormat::CustomOptionsFormat_FLEXBUFFERS)
729     {
730       os << "    ";
731       os << "Unknown custom option format";
732       return;
733     }
734
735     const flatbuffers::Vector<uint8_t> *option_buf = op->custom_options();
736
737     if (option_buf == nullptr || option_buf->size() == 0)
738     {
739       os << "No attrs found." << std::endl;
740       return;
741     }
742
743     // printing attrs
744     // attrs of custom ops are encoded in flexbuffer format
745     auto attr_map = flexbuffers::GetRoot(option_buf->data(), option_buf->size()).AsMap();
746
747     os << "    ";
748     auto keys = attr_map.Keys();
749     for (int i = 0; i < keys.size(); i++)
750     {
751       auto key = keys[i].ToString();
752       os << key << "(" << attr_map[key].ToString() << ") ";
753     }
754
755     // Note: attr in "Shape" type does not seem to be converted by circle_convert.
756     // When the converted circle file (with custom op) is opened with hexa editory,
757     // attrs names can be found but attr name in "Shape" type is not found.
758
759     os << std::endl;
760   }
761 };
762
763 class BCQFullyConnectedPrinter : public OpPrinter
764 {
765 public:
766   void options(const circle::Operator *op, std::ostream &os) const override
767   {
768     if (auto *params = op->builtin_options_as_BCQFullyConnectedOptions())
769     {
770       os << "    ";
771       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
772          << ") ";
773       os << "weights_hidden_size(" << params->weights_hidden_size() << ") ";
774       os << std::endl;
775     }
776   }
777 };
778
779 class BCQGatherPrinter : public OpPrinter
780 {
781 public:
782   void options(const circle::Operator *op, std::ostream &os) const override
783   {
784     if (auto *params = op->builtin_options_as_BCQGatherOptions())
785     {
786       os << "    ";
787       os << "axis(" << params->axis() << ") ";
788       os << "weights_hidden_size(" << params->input_hidden_size() << ") ";
789       os << std::endl;
790     }
791   }
792 };
793
794 class InstanceNormPrinter : public OpPrinter
795 {
796 public:
797   void options(const circle::Operator *op, std::ostream &os) const override
798   {
799     if (auto *params = op->builtin_options_as_InstanceNormOptions())
800     {
801       os << "    ";
802       os << "epsilon(" << params->epsilon() << ") ";
803       os << "Activation(" << EnumNameActivationFunctionType(params->fused_activation_function())
804          << ") ";
805       os << std::endl;
806     }
807   }
808 };
809
810 OpPrinterRegistry::OpPrinterRegistry()
811 {
812   _op_map[circle::BuiltinOperator_ADD] = make_unique<AddPrinter>();
813   // There is no Option for ADD_N
814   _op_map[circle::BuiltinOperator_ARG_MAX] = make_unique<ArgMaxPrinter>();
815   _op_map[circle::BuiltinOperator_ARG_MIN] = make_unique<ArgMinPrinter>();
816   _op_map[circle::BuiltinOperator_AVERAGE_POOL_2D] = make_unique<Pool2DPrinter>();
817   _op_map[circle::BuiltinOperator_BATCH_MATMUL] = make_unique<BatchMatMulPrinter>();
818   _op_map[circle::BuiltinOperator_BIDIRECTIONAL_SEQUENCE_LSTM] =
819     make_unique<BidirectionalSequenceLSTMPrinter>();
820   _op_map[circle::BuiltinOperator_CAST] = make_unique<CastPrinter>();
821   // There is no Option for CEIL
822   _op_map[circle::BuiltinOperator_CONCATENATION] = make_unique<ConcatenationPrinter>();
823   _op_map[circle::BuiltinOperator_CONV_2D] = make_unique<Conv2DPrinter>();
824   // There is no Option for DENSIFY
825   _op_map[circle::BuiltinOperator_DEPTH_TO_SPACE] = make_unique<DepthToSpacePrinter>();
826   _op_map[circle::BuiltinOperator_DEPTHWISE_CONV_2D] = make_unique<DepthwiseConv2DPrinter>();
827   // There is no Option for DEQUANTIZE
828   _op_map[circle::BuiltinOperator_DIV] = make_unique<DivPrinter>();
829   _op_map[circle::BuiltinOperator_FAKE_QUANT] = make_unique<FakeQuantPrinter>();
830   // There is no Option for FLOOR
831   // There is no Option for FLOOR_MOD
832   _op_map[circle::BuiltinOperator_FULLY_CONNECTED] = make_unique<FullyConnectedPrinter>();
833   _op_map[circle::BuiltinOperator_GATHER] = make_unique<GatherPrinter>();
834   _op_map[circle::BuiltinOperator_GELU] = make_unique<GeluPrinter>();
835   _op_map[circle::BuiltinOperator_IF] = make_unique<IfPrinter>();
836   _op_map[circle::BuiltinOperator_L2_NORMALIZATION] = make_unique<L2NormPrinter>();
837   _op_map[circle::BuiltinOperator_L2_POOL_2D] = make_unique<Pool2DPrinter>();
838   _op_map[circle::BuiltinOperator_LEAKY_RELU] = make_unique<LeakyReluPrinter>();
839   _op_map[circle::BuiltinOperator_LOCAL_RESPONSE_NORMALIZATION] =
840     make_unique<LocalResponseNormalizationPrinter>();
841   // There is no Option for LOG
842   // There is no Option for LOGISTIC
843   // There is no Option for LOG_SOFTMAX
844   _op_map[circle::BuiltinOperator_MAX_POOL_2D] = make_unique<Pool2DPrinter>();
845   _op_map[circle::BuiltinOperator_MIRROR_PAD] = make_unique<MirrorPadPrinter>();
846   _op_map[circle::BuiltinOperator_MUL] = make_unique<MulPrinter>();
847   // There is no Option for NON_MAX_SUPPRESSION_V4
848   // There is no Option for NON_MAX_SUPPRESSION_V5
849   _op_map[circle::BuiltinOperator_ONE_HOT] = make_unique<OneHotPrinter>();
850   _op_map[circle::BuiltinOperator_PACK] = make_unique<PackPrinter>();
851   // There is no Option for PAD
852   // There is no Option for PADV2
853   // There is no Option for PRELU
854   // There is no Option for RELU
855   // There is no Option for RELU6
856   // There is no Option for RELU_N1_TO_1
857   _op_map[circle::BuiltinOperator_REDUCE_ANY] = make_unique<ReducerPrinter>();
858   _op_map[circle::BuiltinOperator_REDUCE_MAX] = make_unique<ReducerPrinter>();
859   _op_map[circle::BuiltinOperator_REDUCE_MIN] = make_unique<ReducerPrinter>();
860   _op_map[circle::BuiltinOperator_REDUCE_PROD] = make_unique<ReducerPrinter>();
861   _op_map[circle::BuiltinOperator_RESHAPE] = make_unique<ReshapePrinter>();
862   _op_map[circle::BuiltinOperator_RESIZE_BILINEAR] = make_unique<ResizeBilinearPrinter>();
863   _op_map[circle::BuiltinOperator_RESIZE_NEAREST_NEIGHBOR] =
864     make_unique<ResizeNearestNeighborPrinter>();
865   _op_map[circle::BuiltinOperator_REVERSE_SEQUENCE] = make_unique<ReverseSequencePrinter>();
866   // There is no Option for ROUND
867   // There is no Option for SELECT
868   // There is no Option for SELECT_V2
869   _op_map[circle::BuiltinOperator_SHAPE] = make_unique<ShapePrinter>();
870   // There is no Option for SIN
871   // There is no Option for SLICE
872   _op_map[circle::BuiltinOperator_SOFTMAX] = make_unique<SoftmaxPrinter>();
873   _op_map[circle::BuiltinOperator_SPACE_TO_DEPTH] = make_unique<SpaceToDepthPrinter>();
874   // There is no Option for SPACE_TO_BATCH_ND
875   _op_map[circle::BuiltinOperator_SPARSE_TO_DENSE] = make_unique<SparseToDensePrinter>();
876   _op_map[circle::BuiltinOperator_SPLIT] = make_unique<SplitPrinter>();
877   _op_map[circle::BuiltinOperator_SPLIT_V] = make_unique<SplitVPrinter>();
878   _op_map[circle::BuiltinOperator_SQUEEZE] = make_unique<SqueezePrinter>();
879   _op_map[circle::BuiltinOperator_STRIDED_SLICE] = make_unique<StridedSlicePrinter>();
880   _op_map[circle::BuiltinOperator_SUB] = make_unique<SubPrinter>();
881   _op_map[circle::BuiltinOperator_SUM] = make_unique<ReducerPrinter>();
882   _op_map[circle::BuiltinOperator_SVDF] = make_unique<SVDFPrinter>();
883   _op_map[circle::BuiltinOperator_TRANSPOSE_CONV] = make_unique<TransposeConvPrinter>();
884   // There is no Option for TOPK_V2
885   _op_map[circle::BuiltinOperator_UNIDIRECTIONAL_SEQUENCE_LSTM] =
886     make_unique<UnidirectionalSequenceLSTMPrinter>();
887   _op_map[circle::BuiltinOperator_UNIQUE] = make_unique<UniquePrinter>();
888   _op_map[circle::BuiltinOperator_WHILE] = make_unique<WhilePrinter>();
889   _op_map[circle::BuiltinOperator_CUSTOM] = make_unique<CustomOpPrinter>();
890
891   // Circle only
892   _op_map[circle::BuiltinOperator_BCQ_FULLY_CONNECTED] = make_unique<BCQFullyConnectedPrinter>();
893   _op_map[circle::BuiltinOperator_BCQ_GATHER] = make_unique<BCQGatherPrinter>();
894   _op_map[circle::BuiltinOperator_INSTANCE_NORM] = make_unique<InstanceNormPrinter>();
895 }
896
897 } // namespace circledump