Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 1 | /* |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 2 | * Copyright (c) 2018 ARM Limited. |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 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 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 27 | #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 Pinitas | 7d3d1b9 | 2017-10-12 17:34:20 +0100 | [diff] [blame] | 31 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 32 | #include <limits> |
| 33 | #include <string> |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 34 | |
| 35 | namespace arm_compute |
| 36 | { |
| 37 | namespace graph |
| 38 | { |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 39 | using arm_compute::Status; |
| 40 | |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 41 | using arm_compute::Coordinates; |
| 42 | using arm_compute::DataType; |
Georgios Pinitas | cac13b1 | 2018-04-27 19:07:19 +0100 | [diff] [blame] | 43 | using arm_compute::DataLayout; |
| 44 | using arm_compute::DataLayoutDimension; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 45 | using arm_compute::TensorShape; |
| 46 | using arm_compute::Size2D; |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 47 | using arm_compute::PermutationVector; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 48 | |
| 49 | using arm_compute::ActivationLayerInfo; |
Georgios Pinitas | 6f669f0 | 2017-09-26 12:32:57 +0100 | [diff] [blame] | 50 | using arm_compute::NormType; |
| 51 | using arm_compute::NormalizationLayerInfo; |
Georgios Pinitas | c55cef1 | 2018-08-01 15:24:18 +0100 | [diff] [blame] | 52 | using arm_compute::FullyConnectedLayerInfo; |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 53 | using arm_compute::PadStrideInfo; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 54 | using arm_compute::PoolingLayerInfo; |
| 55 | using arm_compute::PoolingType; |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 56 | using arm_compute::DimensionRoundingType; |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 57 | using arm_compute::InterpolationPolicy; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 58 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 59 | /** TODO (geopin01): Make ids strongly typed */ |
| 60 | using TensorID = unsigned int; |
| 61 | using NodeID = unsigned int; |
| 62 | using EdgeID = unsigned int; |
| 63 | using Activation = arm_compute::ActivationLayerInfo::ActivationFunction; |
Georgios Pinitas | 7d3d1b9 | 2017-10-12 17:34:20 +0100 | [diff] [blame] | 64 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 65 | /**< GraphID strong type */ |
| 66 | using GraphID = strong_type::StrongType<unsigned int, struct graph_id_t, strong_type::Comparable>; |
| 67 | /* TODO (geopin01): Strong types for NodeID */ |
| 68 | |
| 69 | /**< Constant TensorID specifying an equivalent of null tensor */ |
| 70 | constexpr TensorID NullTensorID = std::numeric_limits<TensorID>::max(); |
| 71 | /**< Constant NodeID specifying an equivalent of null node */ |
| 72 | constexpr NodeID EmptyNodeID = std::numeric_limits<NodeID>::max(); |
| 73 | /**< Constant EdgeID specifying an equivalent of null edge */ |
| 74 | constexpr EdgeID EmptyEdgeID = std::numeric_limits<EdgeID>::max(); |
| 75 | |
| 76 | // Forward declarations |
| 77 | class TensorDescriptor; |
| 78 | |
| 79 | /** Graph configuration structure */ |
| 80 | struct GraphConfig |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 81 | { |
Anthony Barbier | 7b607dc | 2018-07-13 15:55:24 +0100 | [diff] [blame] | 82 | bool use_function_memory_manager{ true }; /**< Use a memory manager to manage per-funcion auxilary memory */ |
| 83 | bool use_transition_memory_manager{ true }; /**< Use a memory manager to manager transition buffer memory */ |
| 84 | bool use_tuner{ false }; /**< Use a tuner in tunable backends */ |
| 85 | 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. */ |
| 86 | std::string tuner_file{ "acl_tuner.csv" }; /**< File to load/store tuning values from */ |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 87 | }; |
| 88 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 89 | /**< Device target types */ |
| 90 | enum class Target |
| 91 | { |
| 92 | UNSPECIFIED, /**< Unspecified Target */ |
| 93 | NEON, /**< NEON capable target device */ |
| 94 | CL, /**< OpenCL capable target device */ |
| 95 | GC, /**< GLES compute capable target device */ |
| 96 | }; |
| 97 | |
| 98 | /** Supported Element-wise operations */ |
| 99 | enum class EltwiseOperation |
| 100 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 101 | Add, /**< Arithmetic addition */ |
| 102 | Sub, /**< Arithmetic subtraction */ |
| 103 | Mul /**< Arithmetic multiplication */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | /** Supported Convolution layer methods */ |
| 107 | enum class ConvolutionMethod |
| 108 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 109 | Default, /**< Default approach using internal heuristics */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 110 | GEMM, /**< GEMM based convolution */ |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 111 | Direct, /**< Deep direct convolution */ |
| 112 | Winograd /**< Winograd based convolution */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 113 | }; |
| 114 | |
| 115 | /** Supported Depthwise Convolution layer methods */ |
| 116 | enum class DepthwiseConvolutionMethod |
| 117 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 118 | Default, /**< Default approach using internal heuristics */ |
| 119 | GEMV, /**< Generic GEMV based depthwise convolution */ |
| 120 | Optimized3x3, /**< Optimized 3x3 direct depthwise convolution */ |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 121 | }; |
| 122 | |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 123 | /** Enable or disable fast math for Convolution layer */ |
| 124 | enum class FastMathHint |
| 125 | { |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 126 | Enabled, /**< Fast math enabled for Convolution layer */ |
| 127 | Disabled, /**< Fast math disabled for Convolution layer */ |
Giorgio Arena | 59631a1 | 2018-05-02 13:59:04 +0100 | [diff] [blame] | 128 | }; |
| 129 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 130 | /** Supported nodes */ |
| 131 | enum class NodeType |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 132 | { |
| 133 | ActivationLayer, |
| 134 | BatchNormalizationLayer, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 135 | ChannelShuffleLayer, |
Georgios Pinitas | e222055 | 2018-07-20 13:23:44 +0100 | [diff] [blame] | 136 | ConcatenateLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 137 | ConvolutionLayer, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 138 | DeconvolutionLayer, |
Michalis Spyrou | 7bfe4c5 | 2017-11-24 09:54:20 +0000 | [diff] [blame] | 139 | DepthwiseConvolutionLayer, |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 140 | EltwiseLayer, |
Michalis Spyrou | 27c9efb | 2017-10-09 15:46:30 +0100 | [diff] [blame] | 141 | FlattenLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 142 | FullyConnectedLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 143 | NormalizationLayer, |
Georgios Pinitas | 57c4824 | 2018-08-02 13:41:49 +0100 | [diff] [blame] | 144 | PermuteLayer, |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 145 | PoolingLayer, |
Michalis Spyrou | 27c9efb | 2017-10-09 15:46:30 +0100 | [diff] [blame] | 146 | ReshapeLayer, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 147 | ResizeLayer, |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 148 | SoftmaxLayer, |
| 149 | SplitLayer, |
| 150 | |
| 151 | Input, |
| 152 | Output, |
| 153 | Const, |
Georgios Pinitas | 087eaf6 | 2018-05-16 15:52:35 +0100 | [diff] [blame] | 154 | |
| 155 | Dummy |
Georgios Pinitas | 407c3e6 | 2017-10-25 18:26:46 +0100 | [diff] [blame] | 156 | }; |
| 157 | |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 158 | /** Backend Memory Manager affinity **/ |
| 159 | enum class MemoryManagerAffinity |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 160 | { |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 161 | Buffer, /**< Affinity at buffer level */ |
| 162 | Offset /**< Affinity at offset level */ |
| 163 | }; |
| 164 | |
| 165 | /** NodeID-index struct |
| 166 | * |
| 167 | * Used to describe connections |
| 168 | */ |
| 169 | struct NodeIdxPair |
| 170 | { |
| 171 | NodeID node_id; /**< Node ID */ |
| 172 | size_t index; /**< Index */ |
| 173 | }; |
| 174 | |
| 175 | /** Common node parameters */ |
| 176 | struct NodeParams |
| 177 | { |
| 178 | std::string name; /**< Node name */ |
| 179 | Target target; /**< Node target */ |
Georgios Pinitas | e2c82fe | 2017-10-02 18:51:47 +0100 | [diff] [blame] | 180 | }; |
Anthony Barbier | 2a07e18 | 2017-08-04 18:20:27 +0100 | [diff] [blame] | 181 | } // namespace graph |
| 182 | } // namespace arm_compute |
Georgios Pinitas | d9eb275 | 2018-04-03 13:44:29 +0100 | [diff] [blame] | 183 | #endif /* __ARM_COMPUTE_GRAPH_TYPES_H__ */ |