• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_TYPES_H
25 #define ARM_COMPUTE_GRAPH_TYPES_H
26 
27 #include "arm_compute/core/Error.h"
28 #include "arm_compute/core/PixelValue.h"
29 #include "arm_compute/core/Types.h"
30 #include "arm_compute/runtime/CL/CLTunerTypes.h"
31 
32 #include <limits>
33 #include <string>
34 
35 namespace arm_compute
36 {
37 namespace graph
38 {
39 using arm_compute::CLTunerMode;
40 using arm_compute::Status;
41 
42 using arm_compute::Coordinates;
43 using arm_compute::DataType;
44 using arm_compute::DataLayout;
45 using arm_compute::DataLayoutDimension;
46 using arm_compute::TensorShape;
47 using arm_compute::Size2D;
48 using arm_compute::PermutationVector;
49 using arm_compute::PixelValue;
50 
51 using arm_compute::ActivationLayerInfo;
52 using arm_compute::DetectionOutputLayerInfo;
53 using arm_compute::DetectionPostProcessLayerInfo;
54 using arm_compute::NormType;
55 using arm_compute::NormalizationLayerInfo;
56 using arm_compute::FullyConnectedLayerInfo;
57 using arm_compute::PadStrideInfo;
58 using arm_compute::PoolingLayerInfo;
59 using arm_compute::PoolingType;
60 using arm_compute::PriorBoxLayerInfo;
61 using arm_compute::DimensionRoundingType;
62 using arm_compute::InterpolationPolicy;
63 
64 using GraphID    = unsigned int;
65 using TensorID   = unsigned int;
66 using NodeID     = unsigned int;
67 using EdgeID     = unsigned int;
68 using Activation = arm_compute::ActivationLayerInfo::ActivationFunction;
69 
70 /**< Constant TensorID specifying an equivalent of null tensor */
71 constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max();
72 /**< Constant NodeID specifying an equivalent of null node */
73 constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max();
74 /**< Constant EdgeID specifying an equivalent of null edge */
75 constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max();
76 
77 // Forward declarations
78 struct TensorDescriptor;
79 /** Graph configuration structure */
80 struct GraphConfig
81 {
82     bool        use_function_memory_manager{ true };   /**< Use a memory manager to manage per-function auxilary memory */
83     bool        use_function_weights_manager{ true };  /**< Use a weights manager to manage transformed weights */
84     bool        use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
85     bool        use_tuner{ false };                    /**< Use a tuner in tunable backends */
86     bool        convert_to_uint8{ false };             /**< Convert graph to a synthetic uint8 graph */
87     CLTunerMode tuner_mode{ CLTunerMode::EXHAUSTIVE }; /**< Tuner mode to be used by the CL tuner */
88     int         num_threads{ -1 };                     /**< Number of threads to use (thread capable backends), if 0 the backend will auto-initialize, if -1 the backend will stay as it is. */
89     std::string tuner_file{ "acl_tuner.csv" };         /**< File to load/store tuning values from */
90 };
91 
92 /**< Device target types */
93 enum class Target
94 {
95     UNSPECIFIED, /**< Unspecified Target */
96     NEON,        /**< NEON capable target device */
97     CL,          /**< OpenCL capable target device */
98     GC,          /**< GLES compute capable target device */
99 };
100 
101 /** Supported Element-wise operations */
102 enum class EltwiseOperation
103 {
104     Add, /**< Arithmetic addition */
105     Sub, /**< Arithmetic subtraction */
106     Mul, /**< Arithmetic multiplication */
107     Max, /**< Arithmetic maximum */
108 };
109 
110 /** Supported Unary Element-wise operations */
111 enum class UnaryEltwiseOperation
112 {
113     Exp /**< Exp */
114 };
115 
116 /** Supported Convolution layer methods */
117 enum class ConvolutionMethod
118 {
119     Default, /**< Default approach using internal heuristics */
120     GEMM,    /**< GEMM based convolution */
121     Direct,  /**< Deep direct convolution */
122     Winograd /**< Winograd based convolution */
123 };
124 
125 /** Supported Depthwise Convolution layer methods */
126 enum class DepthwiseConvolutionMethod
127 {
128     Default,      /**< Default approach using internal heuristics */
129     GEMV,         /**< Generic GEMV based depthwise convolution */
130     Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
131 };
132 
133 /** Enable or disable fast math for Convolution layer */
134 enum class FastMathHint
135 {
136     Enabled,  /**< Fast math enabled for Convolution layer */
137     Disabled, /**< Fast math disabled for Convolution layer */
138 };
139 
140 /** Supported nodes */
141 enum class NodeType
142 {
143     ActivationLayer,
144     ArgMinMaxLayer,
145     BatchNormalizationLayer,
146     BoundingBoxTransformLayer,
147     ChannelShuffleLayer,
148     ConcatenateLayer,
149     ConvolutionLayer,
150     DeconvolutionLayer,
151     DepthToSpaceLayer,
152     DepthwiseConvolutionLayer,
153     DequantizationLayer,
154     DetectionOutputLayer,
155     DetectionPostProcessLayer,
156     EltwiseLayer,
157     FlattenLayer,
158     FullyConnectedLayer,
159     FusedConvolutionBatchNormalizationLayer,
160     FusedDepthwiseConvolutionBatchNormalizationLayer,
161     GenerateProposalsLayer,
162     L2NormalizeLayer,
163     NormalizationLayer,
164     NormalizePlanarYUVLayer,
165     PadLayer,
166     PermuteLayer,
167     PoolingLayer,
168     PReluLayer,
169     PrintLayer,
170     PriorBoxLayer,
171     QuantizationLayer,
172     ReductionOperationLayer,
173     ReorgLayer,
174     ReshapeLayer,
175     ResizeLayer,
176     ROIAlignLayer,
177     SoftmaxLayer,
178     SliceLayer,
179     SplitLayer,
180     StackLayer,
181     StridedSliceLayer,
182     UpsampleLayer,
183     UnaryEltwiseLayer,
184     YOLOLayer,
185 
186     Input,
187     Output,
188     Const,
189 
190     Dummy
191 };
192 
193 /** Backend Memory Manager affinity **/
194 enum class MemoryManagerAffinity
195 {
196     Buffer, /**< Affinity at buffer level */
197     Offset  /**< Affinity at offset level */
198 };
199 
200 /** NodeID-index struct
201  *
202  * Used to describe connections
203  */
204 struct NodeIdxPair
205 {
206     NodeID node_id; /**< Node ID */
207     size_t index;   /**< Index */
208 };
209 
210 /** Common node parameters */
211 struct NodeParams
212 {
213     std::string name;   /**< Node name */
214     Target      target; /**< Node target */
215 };
216 } // namespace graph
217 } // namespace arm_compute
218 #endif /* ARM_COMPUTE_GRAPH_TYPES_H */
219