MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / validate

Method validate

src/runtime/NEON/functions/NEPadLayer.cpp:233–281  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

231}
232
233Status NEPadLayer::validate(const ITensorInfo *input,
234 const ITensorInfo *output,
235 const PaddingList &padding,
236 const PixelValue constant_value,
237 const PaddingMode mode)
238{
239 ARM_COMPUTE_TRACE_EVENT(ARM_COMPUTE_PROF_CAT_CPU, ARM_COMPUTE_PROF_LVL_CPU, "NEPadLayer::validate");
240 ARM_COMPUTE_UNUSED(constant_value);
241 ARM_COMPUTE_RETURN_ERROR_ON_DYNAMIC_SHAPE(input, output);
242
243 const TensorShape padded_shape = misc::shape_calculator::compute_padded_shape(input->tensor_shape(), padding);
244
245 if (output->total_size() > 0)
246 {
247 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(output->tensor_shape(), padded_shape);
248 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(input, output);
249 }
250
251 switch (mode)
252 {
253 case PaddingMode::CONSTANT:
254 {
255 return NEPadLayerKernel::validate(input, output, padding, constant_value, mode);
256 }
257 case PaddingMode::REFLECT:
258 case PaddingMode::SYMMETRIC:
259 {
260 for (uint32_t i = 0; i < padding.size(); ++i)
261 {
262 if (mode == PaddingMode::REFLECT)
263 {
264 ARM_COMPUTE_RETURN_ERROR_ON(padding[i].first >= input->dimension(i));
265 ARM_COMPUTE_RETURN_ERROR_ON(padding[i].second >= input->dimension(i));
266 }
267 else
268 {
269 ARM_COMPUTE_RETURN_ERROR_ON(padding[i].first > input->dimension(i));
270 ARM_COMPUTE_RETURN_ERROR_ON(padding[i].second > input->dimension(i));
271 }
272 }
273 break;
274 }
275 default:
276 {
277 ARM_COMPUTE_ERROR("Invalid mode");
278 }
279 }
280 return Status{};
281}
282
283void NEPadLayer::run()
284{

Callers

nothing calls this directly

Calls 5

compute_padded_shapeFunction · 0.85
validateFunction · 0.50
total_sizeMethod · 0.45
sizeMethod · 0.45
dimensionMethod · 0.45

Tested by

no test coverage detected