Compute Library
 21.05
INodeVisitor.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2020 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
24 #ifndef ARM_COMPUTE_GRAPH_INODEVISITOR_H
25 #define ARM_COMPUTE_GRAPH_INODEVISITOR_H
26 
28 
29 namespace arm_compute
30 {
31 namespace graph
32 {
33 /** Node visitor interface */
35 {
36 public:
37  /** Default destructor. */
38  virtual ~INodeVisitor() = default;
39  /** Visit INode.
40  *
41  * @param[in] n Node to visit.
42  */
43  virtual void visit(INode &n) = 0;
44  /** Visit ActivationLayerNode.
45  *
46  * @param[in] n Node to visit.
47  */
48  virtual void visit(ActivationLayerNode &n) = 0;
49  /** Visit BatchNormalizationLayerNode.
50  *
51  * @param[in] n Node to visit.
52  */
53  virtual void visit(BatchNormalizationLayerNode &n) = 0;
54  /** Visit ConcatenateLayerNode.
55  *
56  * @param[in] n Node to visit.
57  */
58  virtual void visit(ConcatenateLayerNode &n) = 0;
59  /** Visit ConstNode.
60  *
61  * @param[in] n Node to visit.
62  */
63  virtual void visit(ConstNode &n) = 0;
64  /** Visit ConvolutionLayerNode.
65  *
66  * @param[in] n Node to visit.
67  */
68  virtual void visit(ConvolutionLayerNode &n) = 0;
69  /** Visit DepthwiseConvolutionLayerNode.
70  *
71  * @param[in] n Node to visit.
72  */
73  virtual void visit(DepthwiseConvolutionLayerNode &n) = 0;
74  /** Visit DequantizationLayerNode.
75  *
76  * @param[in] n Node to visit.
77  */
78  virtual void visit(DequantizationLayerNode &n) = 0;
79  /** Visit DetectionOutputLayerNode.
80  *
81  * @param[in] n Node to visit.
82  */
83  virtual void visit(DetectionOutputLayerNode &n) = 0;
84  /** Visit DetectionPostProcessLayerNode.
85  *
86  * @param[in] n Node to visit.
87  */
88  virtual void visit(DetectionPostProcessLayerNode &n) = 0;
89  /** Visit EltwiseLayerNode.
90  *
91  * @param[in] n Node to visit.
92  */
93  virtual void visit(EltwiseLayerNode &n) = 0;
94  /** Visit FlattenLayerNode.
95  *
96  * @param[in] n Node to visit.
97  */
98  virtual void visit(FlattenLayerNode &n) = 0;
99  /** Visit FullyConnectedLayerNode.
100  *
101  * @param[in] n Node to visit.
102  */
103  virtual void visit(FullyConnectedLayerNode &n) = 0;
104  /** Visit FusedConvolutionBatchNormalizationNode.
105  *
106  * @param[in] n Node to visit.
107  */
108  virtual void visit(FusedConvolutionBatchNormalizationNode &n) = 0;
109  /** Visit FusedDepthwiseConvolutionBatchNormalizationNode.
110  *
111  * @param[in] n Node to visit.
112  */
114  /** Visit InputNode.
115  *
116  * @param[in] n Node to visit.
117  */
118  virtual void visit(InputNode &n) = 0;
119  /** Visit NormalizationLayerNode.
120  *
121  * @param[in] n Node to visit.
122  */
123  virtual void visit(NormalizationLayerNode &n) = 0;
124  /** Visit OutputNode.
125  *
126  * @param[in] n Node to visit.
127  */
128  virtual void visit(OutputNode &n) = 0;
129  /** Visit PermuteLayerNode.
130  *
131  * @param[in] n Node to visit.
132  */
133  virtual void visit(PermuteLayerNode &n) = 0;
134  /** Visit PreluLayerNode.
135  *
136  * @param[in] n Node to visit.
137  */
138  virtual void visit(PReluLayerNode &n) = 0;
139  /** Visit PoolingLayerNode.
140  *
141  * @param[in] n Node to visit.
142  */
143  virtual void visit(PoolingLayerNode &n) = 0;
144  /** Visit PrintLayerNode.
145  *
146  * @param[in] n Node to visit.
147  */
148  virtual void visit(PrintLayerNode &n) = 0;
149  /** Visit PriorBoxLayerNode.
150  *
151  * @param[in] n Node to visit.
152  */
153  virtual void visit(PriorBoxLayerNode &n) = 0;
154  /** Visit QuantizationLayerNode.
155  *
156  * @param[in] n Node to visit.
157  */
158  virtual void visit(QuantizationLayerNode &n) = 0;
159  /** Visit ReshapeLayerNode.
160  *
161  * @param[in] n Node to visit.
162  */
163  virtual void visit(ReshapeLayerNode &n) = 0;
164  /** Visit SoftmaxLayerNode.
165  *
166  * @param[in] n Node to visit.
167  */
168  virtual void visit(SoftmaxLayerNode &n) = 0;
169  /** Visit SplitLayerNode.
170  *
171  * @param[in] n Node to visit.
172  */
173  virtual void visit(SplitLayerNode &n) = 0;
174  /** Visit StackLayerNode.
175  *
176  * @param[in] n Node to visit.
177  */
178  virtual void visit(StackLayerNode &n) = 0;
179 };
180 
181 /** Default visitor implementation
182  *
183  * Implements visit methods by calling a default function.
184  * Inherit from DefaultNodeVisitor if you don't want to provide specific implementation for all nodes.
185  */
187 {
188 public:
189  /** Default destructor */
190  virtual ~DefaultNodeVisitor() = default;
191 
192 #ifndef DOXYGEN_SKIP_THIS
193  // Inherited methods overridden
194  virtual void visit(INode &) override
195  {
196  default_visit();
197  }
198  virtual void visit(ActivationLayerNode &) override
199  {
200  default_visit();
201  }
202  virtual void visit(BatchNormalizationLayerNode &) override
203  {
204  default_visit();
205  }
206  virtual void visit(ConcatenateLayerNode &) override
207  {
208  default_visit();
209  }
210  virtual void visit(ConstNode &) override
211  {
212  default_visit();
213  }
214  virtual void visit(ConvolutionLayerNode &) override
215  {
216  default_visit();
217  }
218  virtual void visit(DequantizationLayerNode &) override
219  {
220  default_visit();
221  }
222  virtual void visit(DetectionOutputLayerNode &) override
223  {
224  default_visit();
225  }
226  virtual void visit(DetectionPostProcessLayerNode &) override
227  {
228  default_visit();
229  }
230  virtual void visit(DepthwiseConvolutionLayerNode &) override
231  {
232  default_visit();
233  }
234  virtual void visit(EltwiseLayerNode &) override
235  {
236  default_visit();
237  }
238  virtual void visit(FlattenLayerNode &) override
239  {
240  default_visit();
241  }
242  virtual void visit(FullyConnectedLayerNode &) override
243  {
244  default_visit();
245  }
246  virtual void visit(FusedConvolutionBatchNormalizationNode &) override
247  {
248  default_visit();
249  }
251  {
252  default_visit();
253  }
254  virtual void visit(InputNode &) override
255  {
256  default_visit();
257  }
258  virtual void visit(NormalizationLayerNode &) override
259  {
260  default_visit();
261  }
262  virtual void visit(OutputNode &) override
263  {
264  default_visit();
265  }
266  virtual void visit(PermuteLayerNode &) override
267  {
268  default_visit();
269  }
270  virtual void visit(PoolingLayerNode &) override
271  {
272  default_visit();
273  }
274  virtual void visit(PReluLayerNode &) override
275  {
276  default_visit();
277  }
278  virtual void visit(PrintLayerNode &) override
279  {
280  default_visit();
281  }
282  virtual void visit(PriorBoxLayerNode &) override
283  {
284  default_visit();
285  }
286  virtual void visit(QuantizationLayerNode &) override
287  {
288  default_visit();
289  }
290  virtual void visit(ReshapeLayerNode &) override
291  {
292  default_visit();
293  }
294  virtual void visit(SoftmaxLayerNode &) override
295  {
296  default_visit();
297  }
298  virtual void visit(SplitLayerNode &) override
299  {
300  default_visit();
301  }
302  virtual void visit(StackLayerNode &) override
303  {
304  default_visit();
305  }
306 #endif /* DOXYGEN_SKIP_THIS */
307 
308  /** Function to be overloaded by the client and implement default behavior for the
309  * non-overloaded visitors
310  */
311  virtual void default_visit() = 0;
312 };
313 } // namespace graph
314 } // namespace arm_compute
315 #endif /* ARM_COMPUTE_GRAPH_INODEVISITOR_H */
Default visitor implementation.
Definition: INodeVisitor.h:186
virtual ~DefaultNodeVisitor()=default
Default destructor.
virtual void default_visit()=0
Function to be overloaded by the client and implement default behavior for the non-overloaded visitor...
Copyright (c) 2017-2021 Arm Limited.
Node interface.
Definition: INode.h:45
virtual void visit(INode &n)=0
Visit INode.
Output Layer node.
Definition: OutputNode.h:34
Input Layer node.
Definition: InputNode.h:34
DetectionPostProcess Layer node.
virtual ~INodeVisitor()=default
Default destructor.
Node visitor interface.
Definition: INodeVisitor.h:34