Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2018 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 | */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 24 | #ifndef __ARM_COMPUTE_GRAPH_INODEVISITOR_H__ |
| 25 | #define __ARM_COMPUTE_GRAPH_INODEVISITOR_H__ |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 26 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 27 | #include "arm_compute/graph/nodes/NodesFwd.h" |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 28 | |
| 29 | namespace arm_compute |
| 30 | { |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 31 | namespace graph |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 32 | { |
| 33 | /** Node visitor interface */ |
| 34 | class INodeVisitor |
| 35 | { |
| 36 | public: |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 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 ConstNode. |
| 55 | * |
| 56 | * @param[in] n Node to visit. |
| 57 | */ |
| 58 | virtual void visit(ConstNode &n) = 0; |
| 59 | /** Visit ConvolutionLayerNode. |
| 60 | * |
| 61 | * @param[in] n Node to visit. |
| 62 | */ |
| 63 | virtual void visit(ConvolutionLayerNode &n) = 0; |
| 64 | /** Visit DepthConcatenateLayerNode. |
| 65 | * |
| 66 | * @param[in] n Node to visit. |
| 67 | */ |
| 68 | virtual void visit(DepthConcatenateLayerNode &n) = 0; |
| 69 | /** Visit DepthwiseConvolutionLayerNode. |
| 70 | * |
| 71 | * @param[in] n Node to visit. |
| 72 | */ |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 73 | virtual void visit(DepthwiseConvolutionLayerNode &n) = 0; |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 74 | /** Visit EltwiseLayerNode. |
| 75 | * |
| 76 | * @param[in] n Node to visit. |
| 77 | */ |
| 78 | virtual void visit(EltwiseLayerNode &n) = 0; |
| 79 | /** Visit FlattenLayerNode. |
| 80 | * |
| 81 | * @param[in] n Node to visit. |
| 82 | */ |
| 83 | virtual void visit(FlattenLayerNode &n) = 0; |
| 84 | /** Visit FullyConnectedLayerNode. |
| 85 | * |
| 86 | * @param[in] n Node to visit. |
| 87 | */ |
| 88 | virtual void visit(FullyConnectedLayerNode &n) = 0; |
| 89 | /** Visit InputNode. |
| 90 | * |
| 91 | * @param[in] n Node to visit. |
| 92 | */ |
| 93 | virtual void visit(InputNode &n) = 0; |
| 94 | /** Visit NormalizationLayerNode. |
| 95 | * |
| 96 | * @param[in] n Node to visit. |
| 97 | */ |
| 98 | virtual void visit(NormalizationLayerNode &n) = 0; |
| 99 | /** Visit OutputNode. |
| 100 | * |
| 101 | * @param[in] n Node to visit. |
| 102 | */ |
| 103 | virtual void visit(OutputNode &n) = 0; |
| 104 | /** Visit PoolingLayerNode. |
| 105 | * |
| 106 | * @param[in] n Node to visit. |
| 107 | */ |
| 108 | virtual void visit(PoolingLayerNode &n) = 0; |
| 109 | /** Visit ReshapeLayerNode. |
| 110 | * |
| 111 | * @param[in] n Node to visit. |
| 112 | */ |
| 113 | virtual void visit(ReshapeLayerNode &n) = 0; |
| 114 | /** Visit SoftmaxLayerNode. |
| 115 | * |
| 116 | * @param[in] n Node to visit. |
| 117 | */ |
| 118 | virtual void visit(SoftmaxLayerNode &n) = 0; |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 119 | /** Visit SplitLayerNode. |
| 120 | * |
| 121 | * @param[in] n Node to visit. |
| 122 | */ |
| 123 | virtual void visit(SplitLayerNode &n) = 0; |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | /** Default visitor implementation |
| 127 | * |
| 128 | * Implements visit methods by calling a default function. |
| 129 | * Inherit from DefaultNodeVisitor if you don't want to provide specific implementation for all nodes. |
| 130 | */ |
| 131 | class DefaultNodeVisitor : public INodeVisitor |
| 132 | { |
| 133 | public: |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 134 | /** Default destructor */ |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 135 | virtual ~DefaultNodeVisitor() = default; |
| 136 | |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 137 | #ifndef DOXYGEN_SKIP_THIS |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 138 | // Inherited methods overridden |
| 139 | virtual void visit(INode &n) override |
| 140 | { |
| 141 | default_visit(); |
| 142 | } |
| 143 | virtual void visit(ActivationLayerNode &n) override |
| 144 | { |
| 145 | default_visit(); |
| 146 | } |
| 147 | virtual void visit(BatchNormalizationLayerNode &n) override |
| 148 | { |
| 149 | default_visit(); |
| 150 | } |
| 151 | virtual void visit(ConstNode &n) override |
| 152 | { |
| 153 | default_visit(); |
| 154 | } |
| 155 | virtual void visit(ConvolutionLayerNode &n) override |
| 156 | { |
| 157 | default_visit(); |
| 158 | } |
| 159 | virtual void visit(DepthConcatenateLayerNode &n) override |
| 160 | { |
| 161 | default_visit(); |
| 162 | } |
| 163 | virtual void visit(DepthwiseConvolutionLayerNode &n) override |
| 164 | { |
| 165 | default_visit(); |
| 166 | } |
| 167 | virtual void visit(EltwiseLayerNode &n) override |
| 168 | { |
| 169 | default_visit(); |
| 170 | } |
| 171 | virtual void visit(FlattenLayerNode &n) override |
| 172 | { |
| 173 | default_visit(); |
| 174 | } |
| 175 | virtual void visit(FullyConnectedLayerNode &n) override |
| 176 | { |
| 177 | default_visit(); |
| 178 | } |
| 179 | virtual void visit(InputNode &n) override |
| 180 | { |
| 181 | default_visit(); |
| 182 | } |
| 183 | virtual void visit(NormalizationLayerNode &n) override |
| 184 | { |
| 185 | default_visit(); |
| 186 | } |
| 187 | virtual void visit(OutputNode &n) override |
| 188 | { |
| 189 | default_visit(); |
| 190 | } |
| 191 | virtual void visit(PoolingLayerNode &n) override |
| 192 | { |
| 193 | default_visit(); |
| 194 | } |
| 195 | virtual void visit(ReshapeLayerNode &n) override |
| 196 | { |
| 197 | default_visit(); |
| 198 | } |
| 199 | virtual void visit(SoftmaxLayerNode &n) override |
| 200 | { |
| 201 | default_visit(); |
| 202 | } |
Georgios Pinitas | ee33ea5 | 2018-03-08 16:01:29 +0000 | [diff] [blame] | 203 | virtual void visit(SplitLayerNode &n) override |
| 204 | { |
| 205 | default_visit(); |
| 206 | } |
Alex Gilday | c357c47 | 2018-03-21 13:54:09 +0000 | [diff] [blame] | 207 | #endif /* DOXYGEN_SKIP_THIS */ |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 208 | |
| 209 | /** Function to be overloaded by the client and implement default behavior for the |
| 210 | * non-overloaded visitors |
| 211 | */ |
| 212 | virtual void default_visit() = 0; |
| 213 | }; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 214 | } // namespace graph |
Georgios Pinitas | d8734b5 | 2017-12-22 15:27:52 +0000 | [diff] [blame] | 215 | } // namespace arm_compute |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 216 | #endif /* __ARM_COMPUTE_GRAPH_INODEVISITOR_H__ */ |