25 const unsigned int numOutputElements)
27 for (
unsigned int i = 0; i < numOutputElements; ++i)
30 outputData.
Set(padValue);
56 assert(numInputDimensions == numOutputDimensions);
60 unsigned int inputBatches = 0;
61 unsigned int inputChannels = 0;
62 unsigned int inputHeight = 0;
63 unsigned int inputWidth = 0;
65 unsigned int outputChannels = 0;
66 unsigned int outputHeight = 0;
67 unsigned int outputWidth = 0;
69 auto inputData = MakeDecoder<float>(inputInfo, data.
m_Inputs[0]->Map());
70 auto outData = MakeEncoder<float>(outputInfo, data.
m_Outputs[0]->Map());
73 if (outputInfo.IsQuantized())
76 auto temporaryInfo =
TensorInfo(outputInfo.GetShape(), outputInfo.GetDataType(), 1.0f, 0);
77 auto outputData = MakeEncoder<float>(temporaryInfo, data.
m_Outputs[0]->Map());
78 FillOutputWithPadValue(*outputData, padValue, numOutputElements);
82 FillOutputWithPadValue(*outData, padValue, numOutputElements);
88 switch(numInputDimensions) {
91 inputWidth = inputShape[0];
92 for (
unsigned int w = 0; w < inputWidth ; w++)
95 auto inputValue = input.
Get();
96 auto outputIndex = w + std::get<0>(padList[0]);
98 output.
Set(inputValue);
103 inputHeight = inputShape[0];
104 inputWidth = inputShape[1];
105 outputWidth = outputShape[1];
107 for (
unsigned int h = 0; h < inputHeight; h++)
109 for (
unsigned int w = 0; w < inputWidth ; w++)
111 input[h * inputWidth + w];
112 auto inputValue = input.
Get();
113 auto outputIndex = (h + std::get<0>(padList[0])) * outputWidth + (w + std::get<0>(padList[1]));
115 output.
Set(inputValue);
121 inputChannels = inputShape[0];
122 inputHeight = inputShape[1];
123 inputWidth = inputShape[2];
124 outputHeight = outputShape[1];
125 outputWidth = outputShape[2];
127 for (
unsigned int c = 0; c < inputChannels; c++)
129 for (
unsigned int h = 0; h < inputHeight; h++)
131 for (
unsigned int w = 0; w < inputWidth ; w++)
133 input[c * inputHeight * inputWidth + h * inputWidth + w];
134 auto inputValue = input.
Get();
135 auto outputIndex = (c + std::get<0>(padList[0])) * outputHeight * outputWidth
136 + (h + std::get<0>(padList[1])) * outputWidth
137 + (w + std::get<0>(padList[2]));
139 output.
Set(inputValue);
146 inputBatches = inputShape[0];
147 inputChannels = inputShape[1];
148 inputHeight = inputShape[2];
149 inputWidth = inputShape[3];
150 outputChannels = outputShape[1];
151 outputHeight = outputShape[2];
152 outputWidth = outputShape[3];
154 for (
unsigned int b = 0; b < inputBatches; b++)
156 for (
unsigned int c = 0; c < inputChannels; c++)
158 for (
unsigned int h = 0; h < inputHeight; h++)
160 for (
unsigned int w = 0; w < inputWidth ; w++)
162 input[b * inputChannels * inputHeight * inputWidth
163 + c * inputHeight * inputWidth
166 auto inputValue = input.
Get();
167 auto outputIndex = (b + std::get<0>(padList[0]))
168 * outputChannels * outputHeight * outputWidth
169 + (c + std::get<0>(padList[1])) * outputHeight * outputWidth
170 + (h + std::get<0>(padList[2])) * outputWidth
171 + (w + std::get<0>(padList[3]));
173 output.
Set(inputValue);
const TensorShape & GetShape() const
float m_PadValue
Optional value to use for padding, defaults to 0.
virtual void Set(IType right)=0
std::vector< std::pair< unsigned int, unsigned int > > m_PadList
Specifies the padding for input dimension.
Copyright (c) 2021 ARM Limited and Contributors.
LayerDescriptor m_Parameters
virtual IType Get() const =0
std::vector< ITensorHandle * > m_Outputs
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
std::vector< ITensorHandle * > m_Inputs
void Pad(const TensorInfo &inputInfo, const TensorInfo &outputInfo, const PadQueueDescriptor &data)
unsigned int GetNumElements() const