48 for(
size_t i = 0; i < padding.size(); ++i)
55 if(output->total_size() > 0)
68 : _input(nullptr), _output(nullptr), _4d_enabled(false)
94 const unsigned int pad_x_before = padding.at(0).first;
95 const unsigned int pad_y_before = padding.size() > 1 ? padding.at(1).first : 0;
96 const unsigned int pad_z_before = padding.size() > 2 ? padding.at(2).first : 0;
98 const unsigned int pad_right_start =
input_width + pad_x_before;
99 const unsigned int pad_x_before_remainder = pad_x_before % vec_size;
109 if(padding.size() > 1)
114 if(padding.size() > 2)
128 const unsigned int vec_size_leftover_read = vec_size - (
ceil_to_multiple(pad_right_start, vec_size) - pad_right_start);
133 if(pad_x_before >= vec_size)
153 const unsigned int pad_x_after_remainder = pad_right_start % vec_size;
154 const unsigned int after_pad_fact_x = (2 *
input_width + pad_x_before) - is_reflect;
155 const unsigned int output_last_x =
ceil_to_multiple(pad_right_start + padding.at(0).second, vec_size);
159 build_opts.add_option(
"-DPAD_X_BEFORE_REMAINDER_REFL=" +
support::cpp11::to_string((pad_x_before_remainder + is_reflect) % vec_size));
160 build_opts.add_option(
"-DPAD_X_AFTER_REMAINDER_REFL=" +
support::cpp11::to_string((pad_x_after_remainder - is_reflect) % vec_size));
162 build_opts.add_option_if(after_pad_fact_x < output_last_x,
"-DAFTER_PAD_REM=" +
support::cpp11::to_string(after_pad_fact_x % vec_size));
175 ICLKernel::configure_internal(win);
192 unsigned int batch = 0;
195 unsigned int idx = 0;
200 add_argument<unsigned int>(idx, batch++);
Class describing the value of a pixel for any image format.
static Status validate(const ITensorInfo *input, const ITensorInfo *output, const PaddingList &padding, PixelValue constant_value=PixelValue(), PaddingMode mode=PaddingMode::CONSTANT)
Static function to check if given info will lead to a valid configuration of CLPadLayerKernel.
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.
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo * > infos)
Stores padding information before configuring a kernel.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
std::vector< PaddingInfo > PaddingList
List of padding information.
void enqueue(cl::CommandQueue &queue, ICLKernel &kernel, const Window &window, const cl::NDRange &lws_hint=CLKernelLibrary::get().default_ndrange(), bool use_dummy_work_items=false)
Add the kernel to the command queue with the given window.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
#define ARM_COMPUTE_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
std::string to_string(T &&value)
Convert integer and float values to string.
size_t element_size_from_data_type(DataType dt)
The size in bytes of the data type.
std::string string_from_pixel_value(const PixelValue &value, const DataType data_type)
Convert a PixelValue to a string, represented through the specific data type.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(...)
void add_3D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 3D tensor's parameters to the object's kernel's arguments starting from the index idx.
Copyright (c) 2017-2021 Arm Limited.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
void add_option(std::string option)
Adds option to the existing build option list.
cl::Kernel create_kernel(const CLCompileContext &ctx, const std::string &kernel_name, const std::set< std::string > &build_opts=std::set< std::string >())
Creates an opencl kernel using a compile context.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
CLPadLayerKernel()
Default constructor.
PaddingMode
Padding mode to use for PadLayer.
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.
Class to describe a number of elements in each dimension.
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
bool auto_init_if_empty(ITensorInfo &info, const TensorShape &shape, int num_channels, DataType data_type, QuantizationInfo quantization_info=QuantizationInfo())
Auto initialize the tensor info (shape, number of channels and data type) if the current assignment i...
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
const size_t input_height
TensorShape compute_padded_shape(const TensorShape &input_shape, const PaddingList &padding)
Calculate the padded shape of a tensor.
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
void configure(const ICLTensor *input, ICLTensor *output, const PaddingList &padding, PixelValue constant_value=PixelValue(), PaddingMode mode=PaddingMode::CONSTANT)
Set the input and output tensor.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
bool has_padding_changed(const std::unordered_map< const ITensorInfo *, PaddingSize > &padding_map)
Check if the previously stored padding info has changed after configuring a kernel.
Interface for OpenCL tensor.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
unsigned int adjust_vec_size(unsigned int vec_size, size_t dim0)
Returns the adjusted vector size in case it is less than the input's first dimension,...
Window first_slice_window_3D() const
First 3D slice of the window.
DataType
Available data types.
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)