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

Function PadTest

delegate/test/PadTestHelper.hpp:157–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

155
156template <typename T>
157void PadTest(tflite::BuiltinOperator padOperatorCode,
158 tflite::TensorType tensorType,
159 const std::vector<int32_t>& inputShape,
160 const std::vector<int32_t>& paddingShape,
161 std::vector<int32_t>& outputShape,
162 std::vector<T>& inputValues,
163 std::vector<int32_t>& paddingDim,
164 std::vector<T>& expectedOutputValues,
165 T paddingValue,
166 const std::vector<armnn::BackendId>& backends = {},
167 float quantScale = 1.0f,
168 int quantOffset = 0,
169 tflite::MirrorPadMode paddingMode = tflite::MirrorPadMode_SYMMETRIC)
170{
171 using namespace delegateTestInterpreter;
172 std::vector<char> modelBuffer = CreatePadTfLiteModel<T>(padOperatorCode,
173 tensorType,
174 paddingMode,
175 inputShape,
176 paddingShape,
177 outputShape,
178 paddingDim,
179 {paddingValue},
180 quantScale,
181 quantOffset);
182
183 // Setup interpreter with just TFLite Runtime.
184 auto tfLiteInterpreter = DelegateTestInterpreter(modelBuffer);
185 CHECK(tfLiteInterpreter.AllocateTensors() == kTfLiteOk);
186 CHECK(tfLiteInterpreter.FillInputTensor<T>(inputValues, 0) == kTfLiteOk);
187 CHECK(tfLiteInterpreter.Invoke() == kTfLiteOk);
188 std::vector<T> tfLiteOutputValues = tfLiteInterpreter.GetOutputResult<T>(0);
189 std::vector<int32_t> tfLiteOutputShape = tfLiteInterpreter.GetOutputShape(0);
190
191 // Setup interpreter with Arm NN Delegate applied.
192 auto armnnInterpreter = DelegateTestInterpreter(modelBuffer, CaptureAvailableBackends(backends));
193 CHECK(armnnInterpreter.AllocateTensors() == kTfLiteOk);
194 CHECK(armnnInterpreter.FillInputTensor<T>(inputValues, 0) == kTfLiteOk);
195 CHECK(armnnInterpreter.Invoke() == kTfLiteOk);
196 std::vector<T> armnnOutputValues = armnnInterpreter.GetOutputResult<T>(0);
197 std::vector<int32_t> armnnOutputShape = armnnInterpreter.GetOutputShape(0);
198
199 armnnDelegate::CompareOutputData<T>(tfLiteOutputValues, armnnOutputValues, expectedOutputValues);
200 armnnDelegate::CompareOutputShape(tfLiteOutputShape, armnnOutputShape, outputShape);
201
202 tfLiteInterpreter.Cleanup();
203 armnnInterpreter.Cleanup();
204}
205
206} // anonymous namespace

Callers

nothing calls this directly

Calls 7

CaptureAvailableBackendsFunction · 0.85
CompareOutputShapeFunction · 0.85
AllocateTensorsMethod · 0.80
InvokeMethod · 0.45
GetOutputShapeMethod · 0.45
CleanupMethod · 0.45

Tested by

no test coverage detected