25 const unsigned int inputSize,
26 const unsigned int padBefore,
27 const unsigned int poolSize,
28 const unsigned int stride)
30 const unsigned int start = std::max(i * stride, padBefore) - padBefore;
31 const unsigned int end = std::min(std::max((i * stride) + poolSize, padBefore) - padBefore, inputSize);
33 return { start, end };
37 template<
typename InputType>
39 const InputType* inputData)
46 armnn::ethosnref::GetOutputTensorData<InputType>(0, data),
54 const unsigned int batchSize = outputInfo.
GetShape()[0];
55 const unsigned int channels = outputInfo.
GetShape()[channelsIndex];
56 const unsigned int outputHeight = outputInfo.
GetShape()[heightIndex];
57 const unsigned int outputWidth = outputInfo.
GetShape()[widthIndex];
58 const unsigned int inputHeight = inputInfo.
GetShape()[heightIndex];
59 const unsigned int inputWidth = inputInfo.
GetShape()[widthIndex];
68 unsigned int inputDataStrides[4] = {};
71 inputDataStrides[0] = inputHeight * inputWidth * channels;
72 inputDataStrides[1] = 1;
73 inputDataStrides[2] = inputWidth * channels;
74 inputDataStrides[3] = channels;
78 inputDataStrides[0] = inputWidth * inputHeight * channels;
79 inputDataStrides[1] = inputWidth * inputHeight;
80 inputDataStrides[2] = inputWidth;
81 inputDataStrides[3] = 1;
86 for (
unsigned int n = 0; n < batchSize; ++n)
88 for (
unsigned int c = 0; c < channels; ++c)
90 for (
unsigned int yOutput = 0; yOutput < outputHeight; ++yOutput)
92 for (
unsigned int xOutput = 0; xOutput < outputWidth; ++xOutput)
95 int poolAreaSize =
numeric_cast<
int>(poolWidth * poolHeight);
100 for (
auto yInput = ySpan.first; yInput < ySpan.second; ++yInput)
102 for (
auto xInput = xSpan.first; xInput < xSpan.second; ++xInput)
104 unsigned int inputIndex = n * inputDataStrides[0] +
105 c * inputDataStrides[1] +
106 yInput * inputDataStrides[2] +
107 xInput * inputDataStrides[3];
115 poolAreaSize =
numeric_cast<
int>((xSpan.second - xSpan.first) * (ySpan.second - ySpan.first));
118 result = (result + (poolAreaSize / 2)) / poolAreaSize;
unsigned int GetWidthIndex() const
const TensorShape & GetShape() const
uint32_t m_PadLeft
Padding left value in the width dimension.
uint32_t m_PoolWidth
Pooling width value.
The padding fields don't count and are ignored.
PaddingMethod m_PaddingMethod
The padding method to be used. (Exclude, IgnoreValue).
uint32_t m_PadTop
Padding top value in the height dimension.
constexpr std::pair< unsigned int, unsigned int > GetAccumulationLimits(const unsigned int i, const unsigned int inputSize, const unsigned int padBefore, const unsigned int poolSize, const unsigned int stride)
Copyright (c) 2021 ARM Limited and Contributors.
LayerDescriptor m_Parameters
uint32_t m_StrideX
Stride value when proceeding through input for the width dimension.
unsigned int GetHeightIndex() const
DataType & Get(unsigned int b, unsigned int c, unsigned int h, unsigned int w) const
PaddingMethod
The padding method modifies the output of pooling layers.
uint32_t m_PoolHeight
Pooling height value.
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
Provides access to the appropriate indexes for Channels, Height and Width based on DataLayout...
DataLayout m_DataLayout
The data layout to be used (NCHW, NHWC).
void EthosnRefPooling2d(const Pooling2dQueueDescriptor &data, const InputType *inputData)
PoolingAlgorithm m_PoolType
The pooling algorithm to use (Max. Average, L2).
std::vector< ITensorHandle * > m_Outputs
std::enable_if_t< std::is_unsigned< Source >::value &&std::is_unsigned< Dest >::value, Dest > numeric_cast(Source source)
std::vector< ITensorHandle * > m_Inputs
unsigned int GetChannelsIndex() const
uint32_t m_StrideY
Stride value when proceeding through input for the height dimension.