Compute Library
 21.02
arm_compute::scale_utils Namespace Reference

Functions

float calculate_resize_ratio (size_t input_size, size_t output_size, bool align_corners=false)
 Returns resize ratio between input and output with consideration of aligned corners. More...
 
bool is_align_corners_allowed_sampling_policy (SamplingPolicy sampling_policy)
 Returns if aligned corners are allowed for the given sampling policy. More...
 

Function Documentation

◆ calculate_resize_ratio()

float calculate_resize_ratio ( size_t  input_size,
size_t  output_size,
bool  align_corners = false 
)

Returns resize ratio between input and output with consideration of aligned corners.

Parameters
[in]input_sizeThe input size
[in]output_sizethe output size
[in]align_cornersTrue to align corners of input and output. Defaults to false.
Returns
The ratio between input and output (i.e., the input size divided by the output size)

Definition at line 27 of file ScaleUtils.cpp.

References ARM_COMPUTE_ERROR_ON, and offset().

Referenced by arm_compute::cpu::bilinear_neon_scale(), NEScale::configure(), NEScaleKernel::configure(), arm_compute::cpu::nearest_neon_scale(), and arm_compute::test::validation::reference::scale_core().

28 {
29  const size_t offset = (align_corners && output_size > 1) ? 1 : 0;
30  const auto in = input_size - offset;
31  const auto out = output_size - offset;
32 
33  ARM_COMPUTE_ERROR_ON((input_size == 0 || output_size == 0) && offset == 1);
34  ARM_COMPUTE_ERROR_ON(out == 0);
35 
36  return static_cast<float>(in) / static_cast<float>(out);
37 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:846
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466

◆ is_align_corners_allowed_sampling_policy()

bool arm_compute::scale_utils::is_align_corners_allowed_sampling_policy ( SamplingPolicy  sampling_policy)
inline

Returns if aligned corners are allowed for the given sampling policy.

Parameters
[in]sampling_policyThe sampling policy to consider
Returns
True if aligned corners are allowed

Definition at line 52 of file ScaleUtils.h.

References arm_compute::CENTER.

Referenced by NEScale::configure().

53 {
54  return sampling_policy != SamplingPolicy::CENTER;
55 }