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

Function validate_arguments

src/cpu/kernels/CpuScaleKernel.cpp:338–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

336};
337
338Status validate_arguments(const ITensorInfo *src,
339 const ITensorInfo *dx,
340 const ITensorInfo *dy,
341 const ITensorInfo *offsets,
342 ITensorInfo *dst,
343 const ScaleKernelInfo &info)
344{
345 ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(src, dst);
346 const auto *uk = CpuScaleKernel::get_implementation(
347 ScaleKernelDataTypeISASelectorData{src->data_type(), CPUInfo::get().get_isa(), info.interpolation_policy});
348
349 ARM_COMPUTE_RETURN_ERROR_ON(uk == nullptr || uk->ukernel == nullptr);
350 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(src, dst);
351 ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(src, dst);
352 ARM_COMPUTE_RETURN_ERROR_ON(dst == src);
353 ARM_COMPUTE_RETURN_ERROR_ON(src->num_channels() != 1);
354 ARM_COMPUTE_RETURN_ERROR_ON(info.sampling_policy != SamplingPolicy::CENTER &&
355 info.sampling_policy != SamplingPolicy::TOP_LEFT);
356 ARM_COMPUTE_UNUSED(info.constant_border_value);
357 ARM_COMPUTE_RETURN_ERROR_ON_MSG(info.use_padding, "Padding is not supported");
358
359 const DataLayout data_layout = info.data_layout == DataLayout::UNKNOWN ? src->data_layout() : info.data_layout;
360 const auto width_index = get_data_layout_dimension_index(data_layout, DataLayoutDimension::WIDTH);
361 const auto height_index = get_data_layout_dimension_index(data_layout, DataLayoutDimension::HEIGHT);
362 const auto output_width = dst->dimension(width_index);
363 const auto output_height = dst->dimension(height_index);
364 ARM_COMPUTE_RETURN_ERROR_ON(output_width == 0);
365 ARM_COMPUTE_RETURN_ERROR_ON(output_height == 0);
366
367 ARM_COMPUTE_RETURN_ERROR_ON((src->data_type() == DataType::S8) &&
368 (data_layout != DataLayout::NHWC ||
369 info.interpolation_policy != InterpolationPolicy::BILINEAR ||
370 info.border_mode != BorderMode::REPLICATE));
371
372 if (offsets != nullptr)
373 {
374 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(offsets);
375 }
376
377 if (info.interpolation_policy == InterpolationPolicy::NEAREST_NEIGHBOR && offsets != nullptr)
378 {
379 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(offsets, 1, DataType::S32);
380 }
381
382 if (info.interpolation_policy == InterpolationPolicy::BILINEAR && offsets != nullptr)
383 {
384 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(offsets, 1, DataType::S32);
385 if (dx != nullptr && dy != nullptr)
386 {
387 ARM_COMPUTE_RETURN_ERROR_ON_SIZE_UNSUPPORTED(dx, dy);
388 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(dx, 1, DataType::F32);
389 ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(dy, 1, DataType::F32);
390 }
391 }
392
393 ARM_COMPUTE_RETURN_ERROR_ON(info.align_corners &&
394 !scale_utils::is_align_corners_allowed_sampling_policy(info.sampling_policy));
395

Callers 2

configureMethod · 0.70
validateMethod · 0.70

Calls 7

get_isaMethod · 0.80
get_implementationFunction · 0.50
data_typeMethod · 0.45
num_channelsMethod · 0.45
data_layoutMethod · 0.45
dimensionMethod · 0.45

Tested by

no test coverage detected