45 Status
validate_arguments(
const ITensorInfo *input1,
const ITensorInfo *input2,
const ITensorInfo *output,
const PriorBoxLayerInfo &
info)
53 const int var_size = info.variances().size();
57 for(
int i = 0; i < var_size; ++i)
65 if(!info.max_sizes().empty())
70 for(
unsigned int i = 0; i < info.max_sizes().size(); ++i)
75 if(output !=
nullptr && output->total_size() != 0)
83 std::pair<Status, Window> validate_and_configure_window(
const ITensorInfo *input1,
const ITensorInfo *input2, ITensorInfo *output,
const PriorBoxLayerInfo &info,
int num_priors)
92 AccessWindowHorizontal output_access(output, 0, num_elems_processed_per_iteration);
95 return std::make_pair(err, win);
100 : _input1(nullptr), _input2(nullptr), _output(nullptr), _info(), _num_priors(), _min(), _max(), _aspect_ratios()
110 cl::Buffer *max, cl::Buffer *aspect_ratios)
120 _aspect_ratios = aspect_ratios;
132 const int layer_width = input1->
info()->
dimension(width_idx);
133 const int layer_height = input1->
info()->
dimension(height_idx);
137 if(img_width == 0 || img_height == 0)
143 float step_x = info.
steps()[0];
144 float step_y = info.
steps()[0];
145 if(step_x == 0.f || step_y == 0.f)
147 step_x =
static_cast<float>(img_width) / layer_width;
148 step_y =
static_cast<float>(img_height) / layer_height;
166 for(
unsigned int i = 0; i < info.
variances().size(); ++i)
173 for(
unsigned int i = 0; i < 4; ++i)
182 _kernel.setArg(idx++, *_min);
183 _kernel.setArg(idx++, *_max);
184 _kernel.setArg(idx++, *_aspect_ratios);
185 _kernel.setArg<
unsigned int>(idx++, info.
min_sizes().size());
186 _kernel.setArg<
unsigned int>(idx++, info.
max_sizes().size());
187 _kernel.setArg<
unsigned int>(idx++, info.
aspect_ratios().size());
190 auto win_config = validate_and_configure_window(input1->
info(), input2->
info(), output->
info(),
info, _num_priors);
193 ICLKernel::configure_internal(win_config.second);
212 queue.enqueueWriteBuffer(*_min, CL_TRUE, 0, _info.
min_sizes().size() *
sizeof(float), _info.
min_sizes().data());
213 queue.enqueueWriteBuffer(*_aspect_ratios, CL_TRUE, 0, _info.
aspect_ratios().size() *
sizeof(float), _info.
aspect_ratios().data());
216 queue.enqueueWriteBuffer(*_max, CL_TRUE, 0, _info.
max_sizes().size() *
sizeof(float), _info.
max_sizes().data());
222 unsigned int idx = 0;
Window first_slice_window_2D() const
First 2D slice of the window.
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 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.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
const StringSet & options() const
Gets the current options list set.
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.
std::vector< float > aspect_ratios() const
Get aspect ratios.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
1 channel, 1 F32 per channel
void configure(const ICLTensor *input1, const ICLTensor *input2, ICLTensor *output, const PriorBoxLayerInfo &info, cl::Buffer *min, cl::Buffer *max, cl::Buffer *aspect_ratios)
Set the input and output tensors.
const DataLayout data_layout
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
Store the tensor's metadata.
#define ARM_COMPUTE_ERROR_THROW_ON(status)
Describe one of the image's dimensions with a start, end and step.
#define ARM_COMPUTE_RETURN_ERROR_ON(cond)
If the condition is true, an error is returned.
static Status validate(const ITensorInfo *input1, const ITensorInfo *input2, const ITensorInfo *output, const PriorBoxLayerInfo &info)
Static function to check if given info will lead to a valid configuration of CLPriorBoxLayerKernel.
Copyright (c) 2017-2021 Arm Limited.
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_ERROR_ON_NULLPTR(...)
void add_option(std::string option)
Adds option to the existing build option list.
TensorShape compute_prior_box_shape(const ITensorInfo &input, const PriorBoxLayerInfo &info)
Calculate the prior box output shape of a tensor.
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.
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
std::array< float, 2 > steps() const
Get the step coordinates.
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 std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
float offset() const
Get the offset.
void add_option_if(bool cond, std::string option)
Adds option if a given condition is true;.
void set(size_t dimension, const Dimension &dim)
Set the values of a given dimension.
static constexpr unsigned int num_arguments_per_2D_tensor()
Returns the number of arguments enqueued per 2D tensor object.
Coordinates2D img_size() const
Get the image size coordinates.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
void add_2D_tensor_argument(unsigned int &idx, const ICLTensor *tensor, const Window &window)
Add the passed 2D tensor's parameters to the object's kernel's arguments starting from the index idx...
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Interface for OpenCL tensor.
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)
Creates an error with a given message.
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context...
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
std::vector< float > max_sizes() const
Get max sizes.
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Status validate_arguments(const ITensorInfo *input, const ITensorInfo *bias, const ITensorInfo *output, const GEMMLowpOutputStageInfo *output_stage)
CLPriorBoxLayerKernel()
Constructor.
std::vector< float > variances() const
Get min variances.
unsigned int num_elems_processed_per_iteration
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
#define ARM_COMPUTE_ERROR_ON_NULLPTR(...)
size_t get_data_layout_dimension_index(const DataLayout data_layout, const DataLayoutDimension data_layout_dimension)
Get the index of the given dimension.
bool clip() const
Get the clip value.
DataLayout
[DataLayout enum definition]
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)
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.
std::vector< float > min_sizes() const
Get min sizes.