blob: 60fe0a883edd4e89fabbb7c4aabb6f15044fa842 [file] [log] [blame]
Anthony Barbier2a07e182017-08-04 18:20:27 +01001/*
Georgios Pinitasd9eb2752018-04-03 13:44:29 +01002 * Copyright (c) 2018 ARM Limited.
Anthony Barbier2a07e182017-08-04 18:20:27 +01003 *
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
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010027#include "arm_compute/core/Error.h"
28#include "arm_compute/core/Types.h"
Georgios Pinitas7d3d1b92017-10-12 17:34:20 +010029
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010030#include <limits>
31#include <string>
Anthony Barbier2a07e182017-08-04 18:20:27 +010032
33namespace arm_compute
34{
35namespace graph
36{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010037using arm_compute::Status;
38
Georgios Pinitase2c82fe2017-10-02 18:51:47 +010039using arm_compute::Coordinates;
40using arm_compute::DataType;
Georgios Pinitascac13b12018-04-27 19:07:19 +010041using arm_compute::DataLayout;
42using arm_compute::DataLayoutDimension;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010043using arm_compute::TensorShape;
44using arm_compute::Size2D;
Georgios Pinitas57c48242018-08-02 13:41:49 +010045using arm_compute::PermutationVector;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010046
47using arm_compute::ActivationLayerInfo;
Isabella Gottardi7234ed82018-11-27 08:51:10 +000048using arm_compute::DetectionOutputLayerInfo;
Georgios Pinitas6f669f02017-09-26 12:32:57 +010049using arm_compute::NormType;
50using arm_compute::NormalizationLayerInfo;
Georgios Pinitasc55cef12018-08-01 15:24:18 +010051using arm_compute::FullyConnectedLayerInfo;
Georgios Pinitase2c82fe2017-10-02 18:51:47 +010052using arm_compute::PadStrideInfo;
Anthony Barbier2a07e182017-08-04 18:20:27 +010053using arm_compute::PoolingLayerInfo;
54using arm_compute::PoolingType;
Pablo Tello32521432018-11-15 14:43:10 +000055using arm_compute::PriorBoxLayerInfo;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010056using arm_compute::DimensionRoundingType;
Georgios Pinitas087eaf62018-05-16 15:52:35 +010057using arm_compute::InterpolationPolicy;
Anthony Barbier2a07e182017-08-04 18:20:27 +010058
Georgios Pinitas54c92fd2018-11-05 12:16:15 +000059using GraphID = unsigned int;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010060using TensorID = unsigned int;
61using NodeID = unsigned int;
62using EdgeID = unsigned int;
63using Activation = arm_compute::ActivationLayerInfo::ActivationFunction;
Georgios Pinitas7d3d1b92017-10-12 17:34:20 +010064
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010065/**< Constant TensorID specifying an equivalent of null tensor */
66constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max();
67/**< Constant NodeID specifying an equivalent of null node */
68constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max();
69/**< Constant EdgeID specifying an equivalent of null edge */
70constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max();
71
72// Forward declarations
73class TensorDescriptor;
74
75/** Graph configuration structure */
76struct GraphConfig
Anthony Barbier2a07e182017-08-04 18:20:27 +010077{
Anthony Barbier7b607dc2018-07-13 15:55:24 +010078 bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-funcion auxilary memory */
79 bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
80 bool use_tuner{ false }; /**< Use a tuner in tunable backends */
81 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. */
82 std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */
Anthony Barbier2a07e182017-08-04 18:20:27 +010083};
84
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010085/**< Device target types */
86enum class Target
87{
88 UNSPECIFIED, /**< Unspecified Target */
89 NEON, /**< NEON capable target device */
90 CL, /**< OpenCL capable target device */
91 GC, /**< GLES compute capable target device */
92};
93
94/** Supported Element-wise operations */
95enum class EltwiseOperation
96{
Georgios Pinitase2220552018-07-20 13:23:44 +010097 Add, /**< Arithmetic addition */
98 Sub, /**< Arithmetic subtraction */
99 Mul /**< Arithmetic multiplication */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100100};
101
102/** Supported Convolution layer methods */
103enum class ConvolutionMethod
104{
Georgios Pinitase2220552018-07-20 13:23:44 +0100105 Default, /**< Default approach using internal heuristics */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100106 GEMM, /**< GEMM based convolution */
Georgios Pinitase2220552018-07-20 13:23:44 +0100107 Direct, /**< Deep direct convolution */
108 Winograd /**< Winograd based convolution */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100109};
110
111/** Supported Depthwise Convolution layer methods */
112enum class DepthwiseConvolutionMethod
113{
Georgios Pinitase2220552018-07-20 13:23:44 +0100114 Default, /**< Default approach using internal heuristics */
115 GEMV, /**< Generic GEMV based depthwise convolution */
116 Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100117};
118
Giorgio Arena59631a12018-05-02 13:59:04 +0100119/** Enable or disable fast math for Convolution layer */
120enum class FastMathHint
121{
Georgios Pinitase2220552018-07-20 13:23:44 +0100122 Enabled, /**< Fast math enabled for Convolution layer */
123 Disabled, /**< Fast math disabled for Convolution layer */
Giorgio Arena59631a12018-05-02 13:59:04 +0100124};
125
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100126/** Supported nodes */
127enum class NodeType
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100128{
129 ActivationLayer,
130 BatchNormalizationLayer,
Manuel Bottinid2048ce2018-10-23 17:00:42 +0100131 BoundingBoxTransformLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100132 ChannelShuffleLayer,
Georgios Pinitase2220552018-07-20 13:23:44 +0100133 ConcatenateLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100134 ConvolutionLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100135 DeconvolutionLayer,
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +0000136 DepthwiseConvolutionLayer,
Isabella Gottardi7234ed82018-11-27 08:51:10 +0000137 DetectionOutputLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100138 EltwiseLayer,
Michalis Spyrou27c9efb2017-10-09 15:46:30 +0100139 FlattenLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100140 FullyConnectedLayer,
Michele Di Giorgio47e6fed2018-11-13 12:04:25 +0000141 GenerateProposalsLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100142 NormalizationLayer,
Michele Di Giorgio555d1102018-09-12 13:51:59 +0100143 NormalizePlanarYUVLayer,
Michele Di Giorgio4bb17332018-09-26 13:56:51 +0100144 PadLayer,
Georgios Pinitas57c48242018-08-02 13:41:49 +0100145 PermuteLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100146 PoolingLayer,
Pablo Tello32521432018-11-15 14:43:10 +0000147 PriorBoxLayer,
Gian Marco Iodice23e24792018-09-07 15:32:14 +0100148 ReorgLayer,
Michalis Spyrou27c9efb2017-10-09 15:46:30 +0100149 ReshapeLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100150 ResizeLayer,
Manuel Bottini3f9d4d72018-10-19 14:04:42 +0100151 ROIAlignLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100152 SoftmaxLayer,
Michele Di Giorgioc30b6682018-09-12 17:44:08 +0100153 SliceLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100154 SplitLayer,
Michalis Spyrou4e1c3f32018-09-20 17:14:03 +0100155 UpsampleLayer,
Michalis Spyrou96f67692018-09-13 11:39:28 +0100156 YOLOLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100157
158 Input,
159 Output,
160 Const,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100161
162 Dummy
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100163};
164
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100165/** Backend Memory Manager affinity **/
166enum class MemoryManagerAffinity
Georgios Pinitase2c82fe2017-10-02 18:51:47 +0100167{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100168 Buffer, /**< Affinity at buffer level */
169 Offset /**< Affinity at offset level */
170};
171
172/** NodeID-index struct
173 *
174 * Used to describe connections
175 */
176struct NodeIdxPair
177{
178 NodeID node_id; /**< Node ID */
179 size_t index; /**< Index */
180};
181
182/** Common node parameters */
183struct NodeParams
184{
185 std::string name; /**< Node name */
186 Target target; /**< Node target */
Georgios Pinitase2c82fe2017-10-02 18:51:47 +0100187};
Anthony Barbier2a07e182017-08-04 18:20:27 +0100188} // namespace graph
189} // namespace arm_compute
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100190#endif /* __ARM_COMPUTE_GRAPH_TYPES_H__ */