blob: b6803c89bc2d22fd45f6ad3812dd7485321bdbec [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;
Georgios Pinitas6f669f02017-09-26 12:32:57 +010048using arm_compute::NormType;
49using arm_compute::NormalizationLayerInfo;
Georgios Pinitasc55cef12018-08-01 15:24:18 +010050using arm_compute::FullyConnectedLayerInfo;
Georgios Pinitase2c82fe2017-10-02 18:51:47 +010051using arm_compute::PadStrideInfo;
Anthony Barbier2a07e182017-08-04 18:20:27 +010052using arm_compute::PoolingLayerInfo;
53using arm_compute::PoolingType;
Pablo Tello32521432018-11-15 14:43:10 +000054using arm_compute::PriorBoxLayerInfo;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010055using arm_compute::DimensionRoundingType;
Georgios Pinitas087eaf62018-05-16 15:52:35 +010056using arm_compute::InterpolationPolicy;
Anthony Barbier2a07e182017-08-04 18:20:27 +010057
Georgios Pinitas54c92fd2018-11-05 12:16:15 +000058using GraphID = unsigned int;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010059using TensorID = unsigned int;
60using NodeID = unsigned int;
61using EdgeID = unsigned int;
62using Activation = arm_compute::ActivationLayerInfo::ActivationFunction;
Georgios Pinitas7d3d1b92017-10-12 17:34:20 +010063
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010064/**< Constant TensorID specifying an equivalent of null tensor */
65constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max();
66/**< Constant NodeID specifying an equivalent of null node */
67constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max();
68/**< Constant EdgeID specifying an equivalent of null edge */
69constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max();
70
71// Forward declarations
72class TensorDescriptor;
73
74/** Graph configuration structure */
75struct GraphConfig
Anthony Barbier2a07e182017-08-04 18:20:27 +010076{
Anthony Barbier7b607dc2018-07-13 15:55:24 +010077 bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-funcion auxilary memory */
78 bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
79 bool use_tuner{ false }; /**< Use a tuner in tunable backends */
80 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. */
81 std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */
Anthony Barbier2a07e182017-08-04 18:20:27 +010082};
83
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010084/**< Device target types */
85enum class Target
86{
87 UNSPECIFIED, /**< Unspecified Target */
88 NEON, /**< NEON capable target device */
89 CL, /**< OpenCL capable target device */
90 GC, /**< GLES compute capable target device */
91};
92
93/** Supported Element-wise operations */
94enum class EltwiseOperation
95{
Georgios Pinitase2220552018-07-20 13:23:44 +010096 Add, /**< Arithmetic addition */
97 Sub, /**< Arithmetic subtraction */
98 Mul /**< Arithmetic multiplication */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010099};
100
101/** Supported Convolution layer methods */
102enum class ConvolutionMethod
103{
Georgios Pinitase2220552018-07-20 13:23:44 +0100104 Default, /**< Default approach using internal heuristics */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100105 GEMM, /**< GEMM based convolution */
Georgios Pinitase2220552018-07-20 13:23:44 +0100106 Direct, /**< Deep direct convolution */
107 Winograd /**< Winograd based convolution */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100108};
109
110/** Supported Depthwise Convolution layer methods */
111enum class DepthwiseConvolutionMethod
112{
Georgios Pinitase2220552018-07-20 13:23:44 +0100113 Default, /**< Default approach using internal heuristics */
114 GEMV, /**< Generic GEMV based depthwise convolution */
115 Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100116};
117
Giorgio Arena59631a12018-05-02 13:59:04 +0100118/** Enable or disable fast math for Convolution layer */
119enum class FastMathHint
120{
Georgios Pinitase2220552018-07-20 13:23:44 +0100121 Enabled, /**< Fast math enabled for Convolution layer */
122 Disabled, /**< Fast math disabled for Convolution layer */
Giorgio Arena59631a12018-05-02 13:59:04 +0100123};
124
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100125/** Supported nodes */
126enum class NodeType
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100127{
128 ActivationLayer,
129 BatchNormalizationLayer,
Manuel Bottinid2048ce2018-10-23 17:00:42 +0100130 BoundingBoxTransformLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100131 ChannelShuffleLayer,
Georgios Pinitase2220552018-07-20 13:23:44 +0100132 ConcatenateLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100133 ConvolutionLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100134 DeconvolutionLayer,
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +0000135 DepthwiseConvolutionLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100136 EltwiseLayer,
Michalis Spyrou27c9efb2017-10-09 15:46:30 +0100137 FlattenLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100138 FullyConnectedLayer,
Michele Di Giorgio47e6fed2018-11-13 12:04:25 +0000139 GenerateProposalsLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100140 NormalizationLayer,
Michele Di Giorgio555d1102018-09-12 13:51:59 +0100141 NormalizePlanarYUVLayer,
Michele Di Giorgio4bb17332018-09-26 13:56:51 +0100142 PadLayer,
Georgios Pinitas57c48242018-08-02 13:41:49 +0100143 PermuteLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100144 PoolingLayer,
Pablo Tello32521432018-11-15 14:43:10 +0000145 PriorBoxLayer,
Gian Marco Iodice23e24792018-09-07 15:32:14 +0100146 ReorgLayer,
Michalis Spyrou27c9efb2017-10-09 15:46:30 +0100147 ReshapeLayer,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100148 ResizeLayer,
Manuel Bottini3f9d4d72018-10-19 14:04:42 +0100149 ROIAlignLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100150 SoftmaxLayer,
Michele Di Giorgioc30b6682018-09-12 17:44:08 +0100151 SliceLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100152 SplitLayer,
Michalis Spyrou4e1c3f32018-09-20 17:14:03 +0100153 UpsampleLayer,
Michalis Spyrou96f67692018-09-13 11:39:28 +0100154 YOLOLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100155
156 Input,
157 Output,
158 Const,
Georgios Pinitas087eaf62018-05-16 15:52:35 +0100159
160 Dummy
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100161};
162
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100163/** Backend Memory Manager affinity **/
164enum class MemoryManagerAffinity
Georgios Pinitase2c82fe2017-10-02 18:51:47 +0100165{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100166 Buffer, /**< Affinity at buffer level */
167 Offset /**< Affinity at offset level */
168};
169
170/** NodeID-index struct
171 *
172 * Used to describe connections
173 */
174struct NodeIdxPair
175{
176 NodeID node_id; /**< Node ID */
177 size_t index; /**< Index */
178};
179
180/** Common node parameters */
181struct NodeParams
182{
183 std::string name; /**< Node name */
184 Target target; /**< Node target */
Georgios Pinitase2c82fe2017-10-02 18:51:47 +0100185};
Anthony Barbier2a07e182017-08-04 18:20:27 +0100186} // namespace graph
187} // namespace arm_compute
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100188#endif /* __ARM_COMPUTE_GRAPH_TYPES_H__ */