2 * Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef __LUCI_LOGEX_CIRCLE_NODE_SUMMARY_BUILDERS__
18 #define __LUCI_LOGEX_CIRCLE_NODE_SUMMARY_BUILDERS__
20 #include "CircleNodeSummaryBuilder.h"
22 #include <luci/IR/CircleNode.h>
30 class CircleNodeWithXSummaryBuilder : public CircleNodeSummaryBuilder
33 std::vector<std::string> get_input_names(const luci::CircleNode *);
36 class CircleNodeWithINPUTSummaryBuilder : public CircleNodeSummaryBuilder
39 std::vector<std::string> get_input_names(const luci::CircleNode *);
42 class CircleNodeWithXYSummaryBuilder : public CircleNodeSummaryBuilder
45 std::vector<std::string> get_input_names(const luci::CircleNode *);
48 class CircleNodeWithFEATURESSummaryBuilder : public CircleNodeSummaryBuilder
51 std::vector<std::string> get_input_names(const luci::CircleNode *);
54 template <class REDUCER_NODE>
55 class CircleNodeWithReducerSummaryBuilder : public CircleNodeSummaryBuilder
58 std::vector<std::string> get_input_names(const luci::CircleNode *)
60 return {"input", "reduction_indices"};
63 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s)
65 auto mean = loco::must_cast<const REDUCER_NODE *>(node);
66 s.args().append("keep_dims", mean->keep_dims() ? "true" : "false");
75 class CircleAbsSummaryBuilder final : public CircleNodeWithXSummaryBuilder
79 class CircleAddSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
82 bool validate(const luci::CircleNode *node);
83 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
86 class CircleAddNSummaryBuilder final : public CircleNodeSummaryBuilder
89 std::vector<std::string> get_input_names(const luci::CircleNode *node);
92 class CircleArgMaxSummaryBuilder final : public CircleNodeSummaryBuilder
95 std::vector<std::string> get_input_names(const luci::CircleNode *);
96 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
99 class CircleArgMinSummaryBuilder final : public CircleNodeSummaryBuilder
102 std::vector<std::string> get_input_names(const luci::CircleNode *);
103 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
106 class CircleAveragePool2DSummaryBuilder final : public CircleNodeSummaryBuilder
109 bool validate(const luci::CircleNode *node);
110 std::vector<std::string> get_input_names(const luci::CircleNode *);
111 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
114 class CircleBatchMatMulSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
117 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
120 class CircleBatchToSpaceNDSummaryBuilder final : public CircleNodeSummaryBuilder
123 std::vector<std::string> get_input_names(const luci::CircleNode *);
126 class CircleBCQFullyConnectedSummaryBuilder final : public CircleNodeSummaryBuilder
129 bool validate(const luci::CircleNode *node);
130 std::vector<std::string> get_input_names(const luci::CircleNode *);
131 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
134 class CircleBCQGatherSummaryBuilder final : public CircleNodeSummaryBuilder
137 std::vector<std::string> get_input_names(const luci::CircleNode *);
138 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
141 class CircleBidirectionalSequenceLSTMSummaryBuilder final : public CircleNodeSummaryBuilder
144 std::vector<std::string> get_input_names(const luci::CircleNode *);
145 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
148 class CircleCastSummaryBuilder final : public CircleNodeSummaryBuilder
151 std::vector<std::string> get_input_names(const luci::CircleNode *);
152 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
155 class CircleCeilSummaryBuilder final : public CircleNodeWithXSummaryBuilder
159 class CircleConcatenationSummaryBuilder final : public CircleNodeSummaryBuilder
162 bool validate(const luci::CircleNode *node);
163 std::vector<std::string> get_input_names(const luci::CircleNode *node);
164 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
167 class CircleConstSummaryBuilder final : public CircleNodeSummaryBuilder
170 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
171 void update_status(locop::NodeSummary &s);
174 class CircleConv2DSummaryBuilder final : public CircleNodeSummaryBuilder
177 bool validate(const luci::CircleNode *node);
178 std::vector<std::string> get_input_names(const luci::CircleNode *);
179 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
182 class CircleCosSummaryBuilder final : public CircleNodeWithXSummaryBuilder
186 class CircleCustomSummaryBuilder final : public CircleNodeSummaryBuilder
189 std::vector<std::string> get_input_names(const luci::CircleNode *node);
190 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
193 class CircleDensifySummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
197 class CircleDepthToSpaceSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
200 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
203 class CircleDepthwiseConv2DSummaryBuilder final : public CircleNodeSummaryBuilder
206 bool validate(const luci::CircleNode *node);
207 std::vector<std::string> get_input_names(const luci::CircleNode *);
208 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
211 class CircleDequantizeSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
215 class CircleDivSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
219 class CircleEluSummaryBuilder final : public CircleNodeWithFEATURESSummaryBuilder
223 class CircleEqualSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
227 class CircleExpSummaryBuilder final : public CircleNodeWithXSummaryBuilder
231 class CircleExpandDimsSummaryBuilder final : public CircleNodeSummaryBuilder
234 std::vector<std::string> get_input_names(const luci::CircleNode *);
237 class CircleFakeQuantSummaryBuilder final : public CircleNodeSummaryBuilder
240 std::vector<std::string> get_input_names(const luci::CircleNode *);
241 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
244 class CircleFillSummaryBuilder final : public CircleNodeSummaryBuilder
247 std::vector<std::string> get_input_names(const luci::CircleNode *);
250 class CircleFloorSummaryBuilder final : public CircleNodeWithXSummaryBuilder
254 class CircleFloorDivSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
258 class CircleFloorModSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
262 class CircleFullyConnectedSummaryBuilder final : public CircleNodeSummaryBuilder
265 bool validate(const luci::CircleNode *node);
266 std::vector<std::string> get_input_names(const luci::CircleNode *);
267 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
270 class CircleGatherSummaryBuilder final : public CircleNodeSummaryBuilder
273 std::vector<std::string> get_input_names(const luci::CircleNode *);
274 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
277 class CircleGatherNdSummaryBuilder final : public CircleNodeSummaryBuilder
280 std::vector<std::string> get_input_names(const luci::CircleNode *);
283 class CircleGreaterSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
287 class CircleGreaterEqualSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
291 class CircleIfSummaryBuilder final : public CircleNodeSummaryBuilder
294 std::vector<std::string> get_input_names(const luci::CircleNode *node);
295 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
298 class CircleInstanceNormSummaryBuilder final : public CircleNodeSummaryBuilder
301 bool validate(const luci::CircleNode *node);
302 std::vector<std::string> get_input_names(const luci::CircleNode *);
303 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
306 class CircleL2NormalizeSummaryBuilder final : public CircleNodeSummaryBuilder
309 bool validate(const luci::CircleNode *node);
310 std::vector<std::string> get_input_names(const luci::CircleNode *);
311 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
314 class CircleL2Pool2DSummaryBuilder final : public CircleNodeSummaryBuilder
317 bool validate(const luci::CircleNode *node);
318 std::vector<std::string> get_input_names(const luci::CircleNode *);
319 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
322 class CircleLeakyReluSummaryBuilder final : public CircleNodeWithFEATURESSummaryBuilder
325 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
328 class CircleLessSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
332 class CircleLessEqualSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
336 class CircleLocalResponseNormalizationSummaryBuilder final
337 : public CircleNodeWithINPUTSummaryBuilder
340 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
343 class CircleLogSummaryBuilder final : public CircleNodeWithXSummaryBuilder
347 class CircleLogicalAndSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
351 class CircleLogicalNotSummaryBuilder final : public CircleNodeWithXSummaryBuilder
355 class CircleLogicalOrSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
359 class CircleLogisticSummaryBuilder final : public CircleNodeWithXSummaryBuilder
363 class CircleLogSoftmaxSummaryBuilder final : public CircleNodeSummaryBuilder
366 std::vector<std::string> get_input_names(const luci::CircleNode *);
369 class CircleMatrixDiagSummaryBuilder final : public CircleNodeSummaryBuilder
372 std::vector<std::string> get_input_names(const luci::CircleNode *);
375 class CircleMatrixSetDiagSummaryBuilder final : public CircleNodeSummaryBuilder
378 std::vector<std::string> get_input_names(const luci::CircleNode *);
381 class CircleMaximumSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
385 class CircleMaxPool2DSummaryBuilder final : public CircleNodeSummaryBuilder
388 bool validate(const luci::CircleNode *node);
389 std::vector<std::string> get_input_names(const luci::CircleNode *);
390 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
393 class CircleMeanSummaryBuilder final : public CircleNodeWithReducerSummaryBuilder<luci::CircleMean>
397 class CircleMinimumSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
401 class CircleMirrorPadSummaryBuilder final : public CircleNodeSummaryBuilder
404 bool validate(const luci::CircleNode *node);
405 std::vector<std::string> get_input_names(const luci::CircleNode *);
406 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
409 class CircleMulSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
412 bool validate(const luci::CircleNode *node);
413 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
416 class CircleNegSummaryBuilder final : public CircleNodeWithXSummaryBuilder
420 class CircleNonMaxSuppressionV4SummaryBuilder final : public CircleNodeSummaryBuilder
423 std::vector<std::string> get_input_names(const luci::CircleNode *);
426 class CircleNonMaxSuppressionV5SummaryBuilder final : public CircleNodeSummaryBuilder
429 std::vector<std::string> get_input_names(const luci::CircleNode *);
432 class CircleNotEqualSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
436 class CircleOneHotSummaryBuilder final : public CircleNodeSummaryBuilder
439 std::vector<std::string> get_input_names(const luci::CircleNode *);
440 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
443 class CirclePackSummaryBuilder final : public CircleNodeSummaryBuilder
446 std::vector<std::string> get_input_names(const luci::CircleNode *node);
447 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
450 class CirclePadSummaryBuilder final : public CircleNodeSummaryBuilder
453 std::vector<std::string> get_input_names(const luci::CircleNode *);
456 class CirclePadV2SummaryBuilder final : public CircleNodeSummaryBuilder
459 std::vector<std::string> get_input_names(const luci::CircleNode *);
462 class CirclePowSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
466 class CirclePReluSummaryBuilder final : public CircleNodeSummaryBuilder
469 std::vector<std::string> get_input_names(const luci::CircleNode *);
472 class CircleQuantizeSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
476 class CircleRangeSummaryBuilder final : public CircleNodeSummaryBuilder
479 std::vector<std::string> get_input_names(const luci::CircleNode *);
482 class CircleRankSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
486 class CircleReduceAnySummaryBuilder final
487 : public CircleNodeWithReducerSummaryBuilder<luci::CircleReduceAny>
491 class CircleReduceMaxSummaryBuilder final
492 : public CircleNodeWithReducerSummaryBuilder<luci::CircleReduceMax>
496 class CircleReduceMinSummaryBuilder final
497 : public CircleNodeWithReducerSummaryBuilder<luci::CircleReduceMin>
501 class CircleReduceProdSummaryBuilder final
502 : public CircleNodeWithReducerSummaryBuilder<luci::CircleReduceProd>
506 class CircleReluSummaryBuilder final : public CircleNodeWithFEATURESSummaryBuilder
510 class CircleRelu6SummaryBuilder final : public CircleNodeWithFEATURESSummaryBuilder
514 class CircleReluN1To1SummaryBuilder final : public CircleNodeWithFEATURESSummaryBuilder
518 class CircleReshapeSummaryBuilder final : public CircleNodeSummaryBuilder
521 std::vector<std::string> get_input_names(const luci::CircleNode *);
522 void update_status(locop::NodeSummary &s);
525 class CircleResizeBilinearSummaryBuilder final : public CircleNodeSummaryBuilder
528 std::vector<std::string> get_input_names(const luci::CircleNode *);
529 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
532 class CircleResizeNearestNeighborSummaryBuilder final : public CircleNodeSummaryBuilder
535 std::vector<std::string> get_input_names(const luci::CircleNode *);
536 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
539 class CircleReverseSequenceSummaryBuilder final : public CircleNodeSummaryBuilder
542 std::vector<std::string> get_input_names(const luci::CircleNode *);
543 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
546 class CircleReverseV2SummaryBuilder final : public CircleNodeSummaryBuilder
549 std::vector<std::string> get_input_names(const luci::CircleNode *);
552 class CircleRoundSummaryBuilder final : public CircleNodeWithXSummaryBuilder
556 class CircleRsqrtSummaryBuilder final : public CircleNodeWithXSummaryBuilder
560 class CircleScatterNdSummaryBuilder final : public CircleNodeSummaryBuilder
563 std::vector<std::string> get_input_names(const luci::CircleNode *);
566 class CircleSegmentSumSummaryBuilder final : public CircleNodeSummaryBuilder
569 std::vector<std::string> get_input_names(const luci::CircleNode *);
572 class CircleSelectSummaryBuilder final : public CircleNodeSummaryBuilder
575 std::vector<std::string> get_input_names(const luci::CircleNode *);
578 class CircleSelectV2SummaryBuilder final : public CircleNodeSummaryBuilder
581 std::vector<std::string> get_input_names(const luci::CircleNode *);
584 class CircleShapeSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
587 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
590 class CircleSinSummaryBuilder final : public CircleNodeWithXSummaryBuilder
594 class CircleSliceSummaryBuilder final : public CircleNodeSummaryBuilder
597 std::vector<std::string> get_input_names(const luci::CircleNode *);
600 class CircleSoftmaxSummaryBuilder final : public CircleNodeSummaryBuilder
603 std::vector<std::string> get_input_names(const luci::CircleNode *);
604 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
607 class CircleSpaceToBatchNDSummaryBuilder final : public CircleNodeSummaryBuilder
610 std::vector<std::string> get_input_names(const luci::CircleNode *);
613 class CircleSpaceToDepthSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
616 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
619 class CircleSparseToDenseSummaryBuilder final : public CircleNodeSummaryBuilder
622 std::vector<std::string> get_input_names(const luci::CircleNode *);
623 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
626 class CircleSplitSummaryBuilder final : public CircleNodeSummaryBuilder
629 std::vector<std::string> get_input_names(const luci::CircleNode *);
630 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
633 class CircleSplitVSummaryBuilder final : public CircleNodeSummaryBuilder
636 std::vector<std::string> get_input_names(const luci::CircleNode *);
637 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
640 class CircleSqrtSummaryBuilder final : public CircleNodeWithXSummaryBuilder
644 class CircleSquareSummaryBuilder final : public CircleNodeWithXSummaryBuilder
648 class CircleSquaredDifferenceSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
652 class CircleSqueezeSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
655 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
658 class CircleStridedSliceSummaryBuilder final : public CircleNodeSummaryBuilder
661 std::vector<std::string> get_input_names(const luci::CircleNode *);
662 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
665 class CircleSubSummaryBuilder final : public CircleNodeWithXYSummaryBuilder
669 class CircleSumSummaryBuilder final : public CircleNodeWithReducerSummaryBuilder<luci::CircleSum>
673 class CircleSVDFSummaryBuilder final : public CircleNodeSummaryBuilder
676 bool validate(const luci::CircleNode *node);
677 std::vector<std::string> get_input_names(const luci::CircleNode *);
679 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
682 class CircleTanhSummaryBuilder final : public CircleNodeWithXSummaryBuilder
686 class CircleTileSummaryBuilder final : public CircleNodeSummaryBuilder
689 std::vector<std::string> get_input_names(const luci::CircleNode *);
692 class CircleTopKV2SummaryBuilder final : public CircleNodeSummaryBuilder
695 std::vector<std::string> get_input_names(const luci::CircleNode *);
698 class CircleTransposeSummaryBuilder final : public CircleNodeSummaryBuilder
701 std::vector<std::string> get_input_names(const luci::CircleNode *);
704 class CircleTransposeConvSummaryBuilder final : public CircleNodeSummaryBuilder
707 bool validate(const luci::CircleNode *node);
708 std::vector<std::string> get_input_names(const luci::CircleNode *);
709 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
712 class CircleUnidirectionalSequenceLSTMSummaryBuilder final : public CircleNodeSummaryBuilder
715 std::vector<std::string> get_input_names(const luci::CircleNode *);
716 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
719 class CircleUniqueSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
722 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
725 class CircleUnpackSummaryBuilder final : public CircleNodeSummaryBuilder
728 std::vector<std::string> get_input_names(const luci::CircleNode *);
729 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
732 class CircleWhereSummaryBuilder final : public CircleNodeSummaryBuilder
735 std::vector<std::string> get_input_names(const luci::CircleNode *);
738 class CircleWhileSummaryBuilder final : public CircleNodeSummaryBuilder
741 std::vector<std::string> get_input_names(const luci::CircleNode *node);
742 void build_attributes(const luci::CircleNode *node, locop::NodeSummary &s);
745 class CircleZerosLikeSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
749 class CircleBidirectionalSequenceLSTMOutSummaryBuilder final
750 : public CircleNodeWithINPUTSummaryBuilder
754 class CircleCustomOutSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
758 class CircleIfOutSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
762 class CircleInputSummaryBuilder final : public CircleNodeSummaryBuilder
766 class CircleNonMaxSuppressionV4OutSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
770 class CircleNonMaxSuppressionV5OutSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
774 class CircleOutputSummaryBuilder final : public CircleNodeSummaryBuilder
777 std::vector<std::string> get_input_names(const luci::CircleNode *);
780 class CircleOutputDummySummaryBuilder final : public CircleNodeSummaryBuilder
784 class CircleOutputExcludeSummaryBuilder final : public CircleNodeSummaryBuilder
788 class CircleSplitOutSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
792 class CircleSplitVOutSummaryBuilder final : public CircleNodeWithINPUTSummaryBuilder
796 class CircleTopKV2OutSummaryBuilder final : public CircleNodeSummaryBuilder
799 std::vector<std::string> get_input_names(const luci::CircleNode *);
802 class CircleUniqueOutSummaryBuilder final : public CircleNodeSummaryBuilder
805 std::vector<std::string> get_input_names(const luci::CircleNode *);
808 class CircleUnpackOutSummaryBuilder final : public CircleNodeSummaryBuilder
811 std::vector<std::string> get_input_names(const luci::CircleNode *);
814 class CircleVariableSummaryBuilder final : public CircleNodeSummaryBuilder
818 class CircleWhileOutSummaryBuilder final : public CircleNodeSummaryBuilder
821 std::vector<std::string> get_input_names(const luci::CircleNode *);
826 #endif // __LUCI_LOGEX_CIRCLE_NODE_SUMMARY_BUILDERS__