14 #include <arm_compute/runtime/FunctionDescriptors.h>
15 #include <arm_compute/function_info/FullyConnectedLayerInfo.h>
17 #if defined(ARMCOMPUTENEON_ENABLED)
21 #if defined(ARMCOMPUTECL_ENABLED)
28 inline arm_compute::NormalizationLayerInfo
33 const unsigned int depth = tensorInfo.
GetShape()[depthDimension];
46 const uint32_t normSize = depth * 2u + 1u;
50 const float alpha = 1.0f;
53 const float kappa = 0.0f;
56 const float beta = 0.5f;
58 return arm_compute::NormalizationLayerInfo(arm_compute::NormType::CROSS_MAP, normSize, alpha, beta, kappa,
false);
66 switch (armnnFunction)
86 inline arm_compute::ActivationLayerInfo
93 inline arm_compute::ActivationLayerInfo
96 if (activationDescPtr !=
nullptr)
101 return arm_compute::ActivationLayerInfo();
104 inline arm_compute::ActivationLayerInfo
109 if (activationDescPtr !=
nullptr)
112 *activationDescPtr));
114 return arm_compute::ActivationLayerInfo();
117 inline arm_compute::ActivationLayerInfo
121 switch (activationFunction)
124 return arm_compute::ActivationLayerInfo();
126 return arm_compute::ActivationLayerInfo(arm_compute::ActivationLayerInfo::ActivationFunction::RELU);
128 return arm_compute::ActivationLayerInfo(
129 arm_compute::ActivationLayerInfo::ActivationFunction::BOUNDED_RELU, 6.0);
131 return arm_compute::ActivationLayerInfo(
132 arm_compute::ActivationLayerInfo::ActivationFunction::TANH, 1.0, 1.0);
134 return arm_compute::ActivationLayerInfo(
135 arm_compute::ActivationLayerInfo::ActivationFunction::LOGISTIC);
157 using arm_compute::PoolingType;
159 switch (poolingAlgorithm)
171 using arm_compute::DimensionRoundingType;
181 inline arm_compute::NormType
184 using arm_compute::NormType;
193 inline arm_compute::FullyConnectedLayerInfo
197 arm_compute::FullyConnectedLayerInfo fc_info;
203 inline arm_compute::FullyConnectedLayerInfo
205 arm_compute::ActivationLayerInfo activationLayerInfo)
207 arm_compute::FullyConnectedLayerInfo fc_info;
209 fc_info.activation_info = activationLayerInfo;
215 switch (resizeMethod)
218 return arm_compute::InterpolationPolicy::BILINEAR;
220 return arm_compute::InterpolationPolicy::NEAREST_NEIGHBOR;
230 if (softmaxDesc.
m_Axis == -1)
239 auto aclAxis = (
static_cast<T
>(dim) - 1);
240 aclAxis = aclAxis > 0 ? aclAxis -1 : aclAxis;
254 int sign = (armnnAxis < 0) ? -1 : 1;
255 int aclAxis = sign * rank - 1 - armnnAxis;
262 bool isFastMathEnabled,
271 const arm_compute::ActivationLayerInfo activationInfo =
273 const auto roundType = arm_compute::DimensionRoundingType::FLOOR;
275 return arm_compute::Conv3dInfo{stride, padding, activationInfo, dilation, roundType, isFastMathEnabled};
279 bool isFastMathEnabled)
282 const arm_compute::Size3D stride{descriptor.
m_StrideX, descriptor.m_StrideY, descriptor.m_StrideZ};
283 const arm_compute::Padding3D padding{descriptor.m_PadLeft, descriptor.m_PadRight,
284 descriptor.m_PadTop, descriptor.m_PadBottom,
285 descriptor.m_PadFront, descriptor.m_PadBack};
286 const arm_compute::Size3D dilation{descriptor.m_DilationX, descriptor.m_DilationY, descriptor.m_DilationZ};
288 const arm_compute::ActivationLayerInfo activationInfo =
290 const auto roundType = arm_compute::DimensionRoundingType::FLOOR;
292 return arm_compute::Conv3dInfo{stride, padding, activationInfo, dilation, roundType, isFastMathEnabled};
321 const std::vector<uint32_t>& vAxis,
324 auto reducedTensorInfo = input;
326 unsigned int outputRank = 0;
332 else if (vAxis.empty())
336 else if (vAxis.size() > reducedTensorInfo.GetNumDimensions())
342 outputRank = reducedTensorInfo.GetNumDimensions() - armnn::numeric_cast<unsigned int>(vAxis.size());
348 std::vector<unsigned int> dimSizes(outputRank, 1);
352 unsigned int outputIndex = 0;
353 for (
unsigned int i = 0; i < reducedTensorInfo.GetNumDimensions(); ++i)
355 if (std::find(vAxis.begin(), vAxis.end(), i) == vAxis.end())
357 dimSizes[outputIndex] = armnn::numeric_cast<unsigned int>(reducedTensorInfo.GetShape()[i]);
362 dimSizes[outputIndex] = 1;
368 reducedTensorInfo.SetShape(inferredShape);
369 return reducedTensorInfo;
385 unsigned int recalulatedAxis = 0;
386 std::vector<uint32_t> axes;
387 axes.reserve(desc.
m_vAxis.size());
389 for (
unsigned int i = 0; i != desc.
m_vAxis.size(); ++i)
391 axes.emplace_back(desc.
m_vAxis[i]);
411 std::vector<uint32_t> singleAxis(1, desc.
m_vAxis[i] - recalulatedAxis);
414 newReduceDescriptor.
m_vAxis.assign(singleAxis.begin(), singleAxis.end());
416 status = func(inputTensorInfo, reducedTensorInfo, newReduceDescriptor);
427 inputTensorInfo = reducedTensorInfo;
#define ARMNN_THROW_INVALIDARG_MSG_IF_FALSE(_cond, _str)
Base class for all ArmNN exceptions so that users can filter to just those.
float GetQuantizationScale() const
unsigned int GetNumDimensions() const
void SetQuantizationScales(const std::vector< float > &scales)
void SetQuantizationOffset(int32_t offset)
void SetQuantizationScale(float scale)
int32_t GetQuantizationOffset() const
const TensorShape & GetShape() const
std::vector< float > GetQuantizationScales() const
bool HasMultipleQuantizationScales() const
Copyright (c) 2021 ARM Limited and Contributors.
arm_compute::ReductionOperation ConvertReductionOperationToAcl(const ReduceDescriptor &descriptor)
PaddingMode
The padding mode controls whether the padding should be filled with constant values (Constant),...
int ComputeAclAxis(const int &armnnAxis, const armnn::TensorInfo &tensor)
Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank,...
@ BoundedReLu
min(a, max(b, input)) ReLu1 & ReLu6.
arm_compute::NormalizationLayerInfo CreateAclNormalizationLayerInfoForL2Normalization(const armnn::TensorInfo &tensorInfo, armnn::DataLayout dataLayout)
arm_compute::Status(*)(const armnn::TensorInfo &, const armnn::TensorInfo &, const armnn::ReduceDescriptor &) reduceValidateFunction
Function pointer type used in IsMultiAxesReduceSupported for readability.
arm_compute::Conv3dInfo ComputeConv3DInfo(const armnn::Convolution3dDescriptor descriptor, bool isFastMathEnabled, const ActivationDescriptor *activationDescriptor)
Utility function used to setup an arm_compute::Conv3dInfo object from convolution3d descriptor.
arm_compute::DimensionRoundingType ConvertOutputShapeRoundingToAclDimensionRoundingType(OutputShapeRounding rounding)
const TensorInfo ComputeReductionTensorShape(const armnn::TensorInfo &input, const std::vector< uint32_t > &vAxis, const bool keepDims)
Function to compute the output tensor shape based on the axes and if keepDims is set.
arm_compute::ActivationLayerInfo ConvertLstmActivationFuncToAclLayerInfo(uint32_t activationFunction)
arm_compute::NormType ConvertNormalizationAlgorithmChannelToAclNormType(NormalizationAlgorithmChannel channelType)
NormalizationAlgorithmChannel
arm_compute::ActivationLayerInfo ConvertAdditionalInfoToAclActivationLayerInfo(const QueueDescriptor &queueDescriptor)
void IsMultiAxesReduceSupported(reduceValidateFunction func, const armnn::TensorInfo &input, const armnn::TensorInfo &output, const armnn::ReduceDescriptor &desc, arm_compute::Status &status)
Function to check if layer with multiple axes is supported on each backend.
arm_compute::ComparisonOperation ConvertComparisonOperationToAcl(const ComparisonDescriptor &descriptor)
arm_compute::PoolingType ConvertPoolingAlgorithmToAclPoolingType(PoolingAlgorithm poolingAlgorithm)
arm_compute::ActivationLayerInfo ConvertActivationDescriptorToAclActivationLayerInfo(const ActivationDescriptor &actDesc)
arm_compute::PaddingMode ConvertPaddingModeToAcl(const PaddingMode &paddingMode)
arm_compute::FullyConnectedLayerInfo ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(const FullyConnectedDescriptor &fullyConnectedDesc, const ActivationDescriptor *activationDesc)
T ComputeSoftmaxAclAxis(const SoftmaxDescriptor &softmaxDesc, const armnn::TensorInfo &tensor)
arm_compute::InterpolationPolicy ConvertResizeMethodToAclInterpolationPolicy(ResizeMethod resizeMethod)
arm_compute::ActivationLayerInfo::ActivationFunction ConvertActivationFunctionToAclActivationFunction(ActivationFunction armnnFunction)
An ActivationDescriptor for the ActivationLayer.
float m_A
Alpha upper bound value used by the activation functions. (BoundedReLu, Linear, TanH,...
float m_B
Beta lower bound value used by the activation functions. (BoundedReLu, Linear, TanH).
ActivationFunction m_Function
The activation function to use (Sigmoid, TanH, Linear, ReLu, BoundedReLu, SoftReLu,...
A ComparisonDescriptor for the ComparisonLayer.
ComparisonOperation m_Operation
Specifies the comparison operation to execute.
A Convolution3dDescriptor for the Convolution3dLayer.
uint32_t m_PadRight
Padding right value in the width dimension.
uint32_t m_PadBack
Padding back value in the depth dimension.
uint32_t m_DilationZ
Dilation along z axis.
uint32_t m_DilationY
Dilation along y axis.
uint32_t m_StrideZ
Stride value when proceeding through input for the depth dimension.
uint32_t m_PadTop
Padding top value in the height dimension.
uint32_t m_PadFront
Padding front value in the depth dimension.
uint32_t m_DilationX
Dilation along x axis.
uint32_t m_PadBottom
Padding bottom value in the height dimension.
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
A FullyConnectedDescriptor for the FullyConnectedLayer.
bool m_TransposeWeightMatrix
Enable/disable transpose weight matrix.
const T * GetAdditionalInformation() const
LayerDescriptor m_Parameters
A ReduceDescriptor for the REDUCE operators.
bool m_KeepDims
if true then output shape has no change.
std::vector< uint32_t > m_vAxis
The indices of the dimensions to reduce.
ReduceOperation m_ReduceOperation
Specifies the reduction operation to execute.
A SoftmaxDescriptor for the SoftmaxLayer.
int m_Axis
Scalar, defaulted to the last index (-1), specifying the dimension the activation will be performed o...