23.08
|
Go to the documentation of this file.
49 for(
size_t i = 0; i < padding.size(); ++i)
56 if(output->total_size() > 0)
69 : _input(nullptr), _output(nullptr), _4d_enabled(false)
96 const unsigned int pad_x_before = padding.at(0).first;
97 const unsigned int pad_y_before = padding.size() > 1 ? padding.at(1).first : 0;
98 const unsigned int pad_z_before = padding.size() > 2 ? padding.at(2).first : 0;
100 const unsigned int pad_right_start =
input_width + pad_x_before;
101 const unsigned int pad_x_before_remainder = pad_x_before % vec_size;
111 if(padding.size() > 1)
116 if(padding.size() > 2)
130 const unsigned int vec_size_leftover_read = vec_size - (
ceil_to_multiple(pad_right_start, vec_size) - pad_right_start);
135 if(pad_x_before >= vec_size)
155 const unsigned int pad_x_after_remainder = pad_right_start % vec_size;
156 const unsigned int after_pad_fact_x = (2 *
input_width + pad_x_before) - is_reflect;
157 const unsigned int output_last_x =
ceil_to_multiple(pad_right_start + padding.at(0).second, vec_size);
161 build_opts.add_option(
"-DPAD_X_BEFORE_REMAINDER_REFL=" +
support::cpp11::to_string((pad_x_before_remainder + is_reflect) % vec_size));
162 build_opts.add_option(
"-DPAD_X_AFTER_REMAINDER_REFL=" +
support::cpp11::to_string((pad_x_after_remainder - is_reflect) % vec_size));
164 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));
177 ICLKernel::configure_internal(win);
194 unsigned int batch = 0;
197 unsigned int idx = 0;
202 add_argument<unsigned int>(idx,
batch++);
Class to describe a number of elements in each dimension.
std::string to_string(T &&value)
Convert integer and float values to string.
Class describing the value of a pixel for any image format.
std::vector< PaddingInfo > PaddingList
List of padding information.
Window calculate_max_window(const ValidRegion &valid_region, const Steps &steps, bool skip_border, BorderSize border_size)
Status validate_arguments(const ITensorInfo *src, const ITensorInfo *weights, const ITensorInfo *dst, const PadStrideInfo &conv_info)
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
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.
Interface for OpenCL tensor.
#define ARM_COMPUTE_ERROR(msg)
Print the given message then throw an std::runtime_error.
size_t element_size_from_data_type(DataType dt)
The size in bytes of the data type.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
PaddingMode
Padding mode to use for PadLayer.
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_RETURN_ON_ERROR(status)
Checks if a status contains an error and returns it.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
void add_option(std::string option)
Adds option to the existing build option list.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
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...
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_ERROR_ON_INVALID_SUBWINDOW(f, s)
bool slide_window_slice_3D(Window &slice) const
Slide the passed 3D window slice.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
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.
Window first_slice_window_3D() const
First 3D slice of the window.
TensorShape compute_padded_shape(const TensorShape &input_shape, const PaddingList &padding)
Calculate the padded shape of a tensor.
const Window & window() const
The maximum window the kernel can be executed on.
std::string get_cl_type_from_data_type(const DataType &dt)
Translates a tensor data type to the appropriate OpenCL type.
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.
CLPadLayerKernel()
Default constructor.
Describe a multidimensional execution window.
@ ELEMENTWISE
Elementwise CL kernel type.
void configure(const ICLTensor *input, ICLTensor *output, const PaddingList &padding, PixelValue constant_value=PixelValue(), PaddingMode mode=PaddingMode::CONSTANT)
Set the input and output tensor.
Copyright (c) 2017-2023 Arm Limited.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DIMENSIONS(...)
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,...
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.
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
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.
Store the tensor's metadata.
@ UNKNOWN
Unknown data type.
DataType
Available data types.
std::unordered_map< const ITensorInfo *, PaddingSize > get_padding_info(std::initializer_list< const ITensorInfo * > infos)
Stores padding information before configuring a kernel.
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
const size_t input_height
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.