81 std::set<std::string> build_opts;
86 build_opts.emplace(
"#define DATA_TYPE_FP16");
90 build_opts.emplace(
"#define SAMPLING_POLICY_TOP_LEFT");
94 build_opts.emplace(
"#define SAMPLING_POLICY_CENTER");
99 unsigned int input_width_alignment = 2;
102 if((fabs(wr - 0.5) < 1e-6) && (fabs(hr - 0.5) < 1e-6) && border_undefined)
104 num_elems_processed_per_iteration = 8;
105 input_width_alignment = 4;
106 build_opts.emplace(
"#define SCALE_NEAREST_8X");
110 build_opts.emplace(
"#define SCALE_NEAREST_GENERIC");
114 std::transform(interpolation_name.begin(), interpolation_name.end(), interpolation_name.begin(),
::tolower);
115 std::string
kernel_name =
"scale_" + interpolation_name;
122 const int total_width = border.
left + input_valid_region.anchor[0] + input_valid_region.shape[0] + border.
right;
123 const int padding_right =
ceil_to_multiple(total_width, input_width_alignment) - border.
left - input_valid_region.anchor[0] - input_valid_region.shape[0];
127 input_valid_region.anchor[0] - border.
left, input_valid_region.anchor[1] - border.
top,
128 input_valid_region.anchor[0] + input_valid_region.shape[0] + padding_right,
129 input_valid_region.anchor[1] + input_valid_region.shape[1] + border.
bottom);
141 IGCKernel::configure(win);
144 _kernel.set_argument<
float>(idx++,
static_cast<float>(input->
info()->
dimension(0)));
145 _kernel.set_argument<
float>(idx++,
static_cast<float>(input->
info()->
dimension(1)));
146 _kernel.set_argument<
float>(idx++, wr);
147 _kernel.set_argument<
float>(idx++, hr);
157 _output->set_needs_shifting(
true);
166 unsigned int idx = 0;
169 _kernel.update_shader_params();
BorderMode border_mode
Border mode policy.
unsigned int top
top of the border
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
const Window & window() const
The maximum window the kernel can be executed on.
void add_3D_tensor_argument(unsigned int &idx, const IGCTensor *tensor, const unsigned int binding_point, const Window &window)
Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx...
BorderSize border_size() const override
The size of the border for that kernel.
InterpolationPolicy interpolation_policy
Interpolation type to use.
void enqueue(IGCKernel &kernel, const Window &window, const gles::NDRange &lws=gles::NDRange(1U, 1U, 1U))
Add the kernel to the command queue with the given window.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
void shift(size_t dimension, int shift_value)
Shift the values of a given dimension by the given shift_value.
Container for 2D border size.
std::string to_string(T &&value)
Convert integer and float values to string.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Interface for GLES Compute tensor.
unsigned int bottom
bottom of the border
unsigned int num_arguments_per_3D_tensor() const
Returns the number of arguments enqueued per 3D tensor object.
Output values are defined to match the source pixel whose center is nearest to the sample position...
Copyright (c) 2017-2021 Arm Limited.
1 channel, 1 F16 per channel
virtual ValidRegion valid_region() const =0
Valid region of the tensor.
ITensorInfo * info() const override
Interface to be implemented by the child class to return the tensor's metadata.
Implementation of a static rectangular access pattern.
void configure(const IGCTensor *input, IGCTensor *output, const ScaleKernelInfo &info)
Initialise the kernel's inputs, output and interpolation policy.
std::string tolower(std::string string)
Convert string to lower case.
static constexpr size_t DimX
Alias for dimension 0 also known as X dimension.
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
SamplingPolicy sampling_policy
Sampling policy used by the interpolation.
virtual const TensorShape & tensor_shape() const =0
Size for each dimension of the tensor.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_DATA_TYPES(...)
auto ceil_to_multiple(S value, T divisor) -> decltype(((value+divisor - 1)/divisor) *divisor)
Computes the smallest number larger or equal to value that is a multiple of divisor.
Manages all the GLES kernels compilation and caching, provides accessors for the GLES Context...
Class to describe a number of elements in each dimension.
Implementation of a row access pattern.
const std::string & string_from_interpolation_policy(InterpolationPolicy policy)
Translates a given interpolation policy to a string.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
Samples are taken at pixel top left corner.
virtual PaddingSize padding() const =0
Padding of tensor.
unsigned int left
left of the border
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
unsigned int right
right of the border
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Output values are determined by averaging the source pixels whose areas fall under the area of the de...
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
ValidRegion calculate_valid_region_scale(const ITensorInfo &src_info, const TensorShape &dst_shape, InterpolationPolicy interpolate_policy, SamplingPolicy sampling_policy, bool border_undefined)
Helper function to calculate the Valid Region for Scale.
Wrapper to configure the Khronos EGL and OpenGL ES C header.
static GCKernelLibrary & get()
Get the static instance of GCKernelLibrary.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Borders are left undefined.
void run(const Window &window) override
Enqueue the OpenGL ES shader to process the given window.
GCKernel create_kernel(const std::string &shader_name, const StringSet &build_options_set={}) const
Creates a kernel from the kernel library.
unsigned int num_elems_processed_per_iteration
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
Container for valid region of a window.
Window first_slice_window_3D() const
First 3D slice of the window.
Describe a multidimensional execution window.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)