2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
12 constexpr unsigned int MaxNumOfTensorDimensions = 4U;
14 /// @enum Status enumeration
15 /// @var Status::Successful
16 /// @var Status::Failure
31 enum class ActivationFunction
37 BoundedReLu = 4, ///< min(a, max(b, input))
45 enum class PoolingAlgorithm
53 /// The padding method modifies the output of pooling layers.
54 /// In both supported methods, the values are ignored (they are
55 /// not even zeroes, which would make a difference for max pooling
56 /// a tensor with negative values). The difference between
57 /// IgnoreValue and Exclude is that the former counts the padding
58 /// fields in the divisor of Average and L2 pooling, while
61 enum class PaddingMethod
63 /// The padding fields count, but are ignored
65 /// The padding fields don't count and are ignored
69 enum class NormalizationAlgorithmChannel
75 enum class NormalizationAlgorithmMethod
77 /// Krichevsky 2012: Local Brightness Normalization
79 /// Jarret 2009: Local Contrast Normalization
83 enum class OutputShapeRounding
91 /// CPU Execution: Reference C++ kernels
93 /// CPU Execution: NEON: ArmCompute
95 /// GPU Execution: OpenCL: ArmCompute
104 virtual ~IDeviceSpec() {};
107 /// Type of identifiers for bindable layers (inputs, outputs).
108 using LayerBindingId = int;
110 class PermutationVector
113 using ValueType = unsigned int;
114 using SizeType = unsigned int;
115 using ArrayType = std::array<ValueType, MaxNumOfTensorDimensions>;
116 using ConstIterator = typename ArrayType::const_iterator;
118 /// @param dimMappings - Indicates how to translate tensor elements from a given source into the target destination,
119 /// when source and target potentially have different memory layouts.
121 /// E.g. For a 4-d tensor laid out in a memory with the format (Batch Element, Height, Width, Channels),
122 /// which is to be passed as an input to ArmNN, each source dimension is mapped to the corresponding
123 /// ArmNN dimension. The Batch dimension remains the same (0 -> 0). The source Height dimension is mapped
124 /// to the location of the ArmNN Height dimension (1 -> 2). Similar arguments are made for the Width and
125 /// Channels (2 -> 3 and 3 -> 1). This will lead to @ref m_DimMappings pointing to the following array:
128 /// Note that the mapping should be reversed if considering the case of ArmNN 4-d outputs (Batch Element,
129 /// Channels, Height, Width) being written to a destination with the format mentioned above. We now have
130 /// 0 -> 0, 2 -> 1, 3 -> 2, 1 -> 3, which, when reordered, lead to the following @ref m_DimMappings contents:
133 PermutationVector(const ValueType *dimMappings, SizeType numDimMappings);
135 PermutationVector(std::initializer_list<ValueType> dimMappings);
137 ValueType operator[](SizeType i) const { return m_DimMappings.at(i); }
139 SizeType GetSize() const { return m_NumDimMappings; }
141 ConstIterator begin() const { return m_DimMappings.begin(); }
142 ConstIterator end() const { return m_DimMappings.end(); }
144 bool IsEqual(const PermutationVector& other) const
146 return std::equal(begin(), end(), other.begin(), other.end());
149 bool IsInverse(const PermutationVector& other) const
151 bool isInverse = (GetSize() == other.GetSize());
152 for (SizeType i = 0; isInverse && (i < GetSize()); ++i)
154 isInverse = (m_DimMappings[other.m_DimMappings[i]] == i);
160 ArrayType m_DimMappings;
161 /// Number of valid entries in @ref m_DimMappings
162 SizeType m_NumDimMappings;
165 /// Define LayerGuid type.
166 using LayerGuid = unsigned int;