MCPcopy Create free account
hub / github.com/ARM-software/armnn / Pad

Function Pad

src/backends/reference/workloads/Pad.cpp:39–233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

37{
38
39void Pad(const TensorInfo& inputInfo,
40 const TensorInfo& outputInfo,
41 const ITensorHandle* inputHandle,
42 ITensorHandle* outputHandle,
43 const PadQueueDescriptor& data)
44{
45 auto padList = data.m_Parameters.m_PadList;
46 auto padValue = data.m_Parameters.m_PadValue;
47
48 unsigned int numOutputElements = outputInfo.GetNumElements();
49
50 TensorShape outputShape = outputInfo.GetShape();
51 TensorShape inputShape = inputInfo.GetShape();
52
53 unsigned int numInputDimensions = inputShape.GetNumDimensions();
54
55#ifndef NDEBUG
56
57 unsigned int numOutputDimensions = outputShape.GetNumDimensions();
58 assert(numInputDimensions == numOutputDimensions);
59
60#endif
61
62 unsigned int inputBatches = 0;
63 unsigned int inputChannels = 0;
64 unsigned int inputHeight = 0;
65 unsigned int inputWidth = 0;
66 unsigned int inputDim5 = 0;
67
68 unsigned int outputBatches = 0;
69 unsigned int outputChannels = 0;
70 unsigned int outputHeight = 0;
71 unsigned int outputWidth = 0;
72
73 auto inputData = MakeDecoder<float>(inputInfo, inputHandle->Map());
74 auto outData = MakeEncoder<float>(outputInfo, outputHandle->Map());
75
76 // Fill the output tensor with Pad value first
77 if (outputInfo.IsQuantized())
78 {
79 // For Quantized types Pad Value should not be quantized with scale and offset of the tensor info
80 auto temporaryInfo = TensorInfo(outputInfo.GetShape(), outputInfo.GetDataType(), 1.0f, 0);
81
82 auto outputData = MakeEncoder<float>(temporaryInfo, outputHandle->Map());
83 FillOutputWithPadValue(*outputData, padValue, numOutputElements);
84 }
85 else
86 {
87 FillOutputWithPadValue(*outData, padValue, numOutputElements);
88 }
89
90 Decoder<float>& input = *inputData;
91 Encoder<float>& output = *outData;
92
93 switch(numInputDimensions) {
94
95 case 1:
96 inputWidth = inputShape[0];

Callers 1

ExecuteMethod · 0.85

Calls 10

FillOutputWithPadValueFunction · 0.85
IsQuantizedMethod · 0.80
TensorInfoClass · 0.50
GetNumElementsMethod · 0.45
GetShapeMethod · 0.45
GetNumDimensionsMethod · 0.45
MapMethod · 0.45
GetDataTypeMethod · 0.45
GetMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected