Imported Upstream version 1.18.0
[platform/core/ml/nnfw.git] / runtime / onert / core / include / ir / operation / DetectionPostProcess.h
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 #ifndef __NEURUN_MODEL_OPERATION_DETECTION_POST_PROCESS_NODE_H__
18 #define __NEURUN_MODEL_OPERATION_DETECTION_POST_PROCESS_NODE_H__
19
20 #include "ir/Operation.h"
21
22 namespace onert
23 {
24 namespace ir
25 {
26 namespace operation
27 {
28
29 class DetectionPostProcess : public Operation
30 {
31 public:
32   enum Input
33   {
34     BOXES = 0,
35     SCORES = 1,
36     INPUT_ANCHORS = 2
37   };
38
39   enum Output
40   {
41     BOX_COORDS = 0,
42     BOX_CLASSES = 1,
43     BOX_SCORES = 2,
44     NUM_SELECTED = 3
45   };
46
47   struct Scale
48   {
49     float y_scale;
50     float x_scale;
51     float h_scale;
52     float w_scale;
53   };
54
55   struct Param
56   {
57     int max_detections;
58     float score_threshold;
59     float iou_threshold; // intersection-over-union
60     int max_boxes_per_class;
61     int32_t num_classes;
62     int32_t max_classes_per_detection;
63     // N*N complexity instead of N*N*M, where N - number of boxes and M number of classes
64     bool center_size_boxes;
65     bool do_fast_eval = true;
66     Scale scale;
67   };
68
69 public:
70   DetectionPostProcess(const OperandIndexSequence &inputs, const OperandIndexSequence &outputs,
71                        const Param &param);
72
73 public:
74   void accept(OperationVisitor &v) const override;
75
76   std::string getName() const { return "DetectionPostProcess"; }
77
78 public:
79   const Param &param() const { return _param; }
80   OpCode opcode() const final { return OpCode::DetectionPostProcess; }
81
82 private:
83   Param _param;
84 };
85
86 } // namespace operation
87 } // namespace ir
88 } // namespace onert
89
90 #endif // __NEURUN_MODEL_OPERATION_DETECTION_POST_PROCESS_NODE_H__