blob: d4e4f99377b8f285d9c06f95fc21db471a8709d2 [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"
29#include "arm_compute/core/utils/strong_type/StrongType.h"
30#include "arm_compute/core/utils/strong_type/StrongTypeAttributes.h"
Georgios Pinitas7d3d1b92017-10-12 17:34:20 +010031
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010032#include <limits>
33#include <string>
Anthony Barbier2a07e182017-08-04 18:20:27 +010034
35namespace arm_compute
36{
37namespace graph
38{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010039using arm_compute::Status;
40
Georgios Pinitase2c82fe2017-10-02 18:51:47 +010041using arm_compute::Coordinates;
42using arm_compute::DataType;
Georgios Pinitascac13b12018-04-27 19:07:19 +010043using arm_compute::DataLayout;
44using arm_compute::DataLayoutDimension;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010045using arm_compute::TensorShape;
46using arm_compute::Size2D;
47
48using arm_compute::ActivationLayerInfo;
Georgios Pinitas6f669f02017-09-26 12:32:57 +010049using arm_compute::NormType;
50using arm_compute::NormalizationLayerInfo;
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;
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010054using arm_compute::DimensionRoundingType;
Anthony Barbier2a07e182017-08-04 18:20:27 +010055
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010056/** TODO (geopin01): Make ids strongly typed */
57using TensorID = unsigned int;
58using NodeID = unsigned int;
59using EdgeID = unsigned int;
60using Activation = arm_compute::ActivationLayerInfo::ActivationFunction;
Georgios Pinitas7d3d1b92017-10-12 17:34:20 +010061
Georgios Pinitasd9eb2752018-04-03 13:44:29 +010062/**< GraphID strong type */
63using GraphID = strong_type::StrongType<unsigned int, struct graph_id_t, strong_type::Comparable>;
64/* TODO (geopin01): Strong types for NodeID */
65
66/**< Constant TensorID specifying an equivalent of null tensor */
67constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max();
68/**< Constant NodeID specifying an equivalent of null node */
69constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max();
70/**< Constant EdgeID specifying an equivalent of null edge */
71constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max();
72
73// Forward declarations
74class TensorDescriptor;
75
76/** Graph configuration structure */
77struct GraphConfig
Anthony Barbier2a07e182017-08-04 18:20:27 +010078{
Georgios Pinitas3d1489d2018-05-03 20:47:16 +010079 bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-funcion auxilary memory */
80 bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */
81 bool use_tuner{ false }; /**< Use a tuner in tunable backends */
82 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. */
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{
97 ADD, /**< Arithmetic addition */
98 SUB, /**< Arithmetic subtraction */
99 MUL /**< Arithmetic multiplication */
100};
101
102/** Supported Convolution layer methods */
103enum class ConvolutionMethod
104{
105 DEFAULT, /**< Default approach using internal heuristics */
106 GEMM, /**< GEMM based convolution */
107 DIRECT, /**< Deep direct convolution */
108 WINOGRAD /**< Winograd based convolution */
109};
110
111/** Supported Depthwise Convolution layer methods */
112enum class DepthwiseConvolutionMethod
113{
114 DEFAULT, /**< Default approach using internal heuristics */
115 GEMV, /**< Generic GEMV based depthwise convolution */
116 OPTIMIZED_3x3, /**< Optimized 3x3 direct depthwise convolution */
117};
118
Giorgio Arena59631a12018-05-02 13:59:04 +0100119/** Enable or disable fast math for Convolution layer */
120enum class FastMathHint
121{
122 ENABLED, /**< Fast math enabled for Convolution layer */
123 DISABLED, /**< Fast math disabled for Convolution layer */
124};
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,
131 ConvolutionLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100132 DepthConcatenateLayer,
Michalis Spyrou7bfe4c52017-11-24 09:54:20 +0000133 DepthwiseConvolutionLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100134 EltwiseLayer,
Michalis Spyrou27c9efb2017-10-09 15:46:30 +0100135 FlattenLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100136 FullyConnectedLayer,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100137 NormalizationLayer,
138 PoolingLayer,
Michalis Spyrou27c9efb2017-10-09 15:46:30 +0100139 ReshapeLayer,
Isabella Gottardi88d5b222018-04-06 12:24:55 +0100140 ScaleLayer,
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100141 SoftmaxLayer,
142 SplitLayer,
143
144 Input,
145 Output,
146 Const,
Georgios Pinitas407c3e62017-10-25 18:26:46 +0100147};
148
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100149/** Backend Memory Manager affinity **/
150enum class MemoryManagerAffinity
Georgios Pinitase2c82fe2017-10-02 18:51:47 +0100151{
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100152 Buffer, /**< Affinity at buffer level */
153 Offset /**< Affinity at offset level */
154};
155
156/** NodeID-index struct
157 *
158 * Used to describe connections
159 */
160struct NodeIdxPair
161{
162 NodeID node_id; /**< Node ID */
163 size_t index; /**< Index */
164};
165
166/** Common node parameters */
167struct NodeParams
168{
169 std::string name; /**< Node name */
170 Target target; /**< Node target */
Georgios Pinitase2c82fe2017-10-02 18:51:47 +0100171};
Anthony Barbier2a07e182017-08-04 18:20:27 +0100172} // namespace graph
173} // namespace arm_compute
Georgios Pinitasd9eb2752018-04-03 13:44:29 +0100174#endif /* __ARM_COMPUTE_GRAPH_TYPES_H__ */