24.02.1
|
Go to the documentation of this file.
46 const ITensorInfo *input2,
47 const ITensorInfo *output,
48 const PriorBoxLayerInfo &
info)
56 const int var_size =
info.variances().size();
60 for (
int i = 0; i < var_size; ++i)
68 if (!
info.max_sizes().empty())
71 "Max and min sizes dimensions should match");
74 for (
unsigned int i = 0; i <
info.max_sizes().size(); ++i)
77 "Max size should be greater than min size");
80 if (output !=
nullptr && output->total_size() != 0)
89 const ITensorInfo *input2,
91 const PriorBoxLayerInfo &
info,
105 return std::make_pair(err, win);
110 : _input1(nullptr), _input2(nullptr), _output(nullptr), _info(), _num_priors(), _min(), _max(), _aspect_ratios()
121 cl::Buffer *aspect_ratios)
133 cl::Buffer *aspect_ratios)
143 _aspect_ratios = aspect_ratios;
148 _num_priors =
info.aspect_ratios().size() *
info.min_sizes().size() +
info.max_sizes().size();
158 int img_width =
info.img_size().x;
159 int img_height =
info.img_size().y;
160 if (img_width == 0 || img_height == 0)
166 float step_x =
info.steps()[0];
167 float step_y =
info.steps()[0];
168 if (step_x == 0.f || step_y == 0.f)
170 step_x =
static_cast<float>(img_width) / layer_width;
171 step_y =
static_cast<float>(img_height) / layer_height;
187 if (
info.variances().size() > 1)
189 for (
unsigned int i = 0; i <
info.variances().size(); ++i)
197 for (
unsigned int i = 0; i < 4; ++i)
207 _kernel.setArg(idx++, *_min);
208 _kernel.setArg(idx++, *_max);
209 _kernel.setArg(idx++, *_aspect_ratios);
210 _kernel.setArg<
unsigned int>(idx++,
info.min_sizes().size());
211 _kernel.setArg<
unsigned int>(idx++,
info.max_sizes().size());
212 _kernel.setArg<
unsigned int>(idx++,
info.aspect_ratios().size());
218 ICLKernel::configure_internal(win_config.second);
228 const int num_priors =
info.aspect_ratios().size() *
info.min_sizes().size() +
info.max_sizes().size();
241 queue.enqueueWriteBuffer(*_min, CL_TRUE, 0, _info.
min_sizes().size() *
sizeof(
float), _info.
min_sizes().data());
242 queue.enqueueWriteBuffer(*_aspect_ratios, CL_TRUE, 0, _info.
aspect_ratios().size() *
sizeof(
float),
246 queue.enqueueWriteBuffer(*_max, CL_TRUE, 0, _info.
max_sizes().size() *
sizeof(
float), _info.
max_sizes().data());
252 unsigned int idx = 0;
std::string to_string(T &&value)
Convert integer and float values to string.
std::vector< float > max_sizes() const
Get max sizes.
std::vector< float > min_sizes() const
Get min sizes.
virtual DataLayout data_layout() const =0
Get the data layout of the tensor.
std::vector< float > aspect_ratios() const
Get aspect ratios.
DataLayout
[DataLayout enum definition]
const StringSet & options() const
Gets the current options list set.
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)
constexpr static unsigned int num_arguments_per_2D_tensor()
Returns the number of arguments enqueued per 2D tensor object.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
Interface for OpenCL tensor.
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.
bool update_window_and_padding(Window &win, Ts &&...patterns)
Update window and padding size for each of the access patterns.
static CLKernelLibrary & get()
Access the KernelLibrary singleton.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_TYPES(...)
#define ARM_COMPUTE_RETURN_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context.
constexpr auto data_layout
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.
#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.
@ RUNTIME_ERROR
Generic runtime error.
#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_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.
CLPriorBoxLayerKernel()
Constructor.
void add_option_if(bool cond, std::string option)
Adds option if a given condition is true;.
#define ARM_COMPUTE_ERROR_ON_INVALID_SUBWINDOW(f, s)
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
#define ARM_COMPUTE_RETURN_ERROR_ON_MISMATCHING_DATA_LAYOUT(...)
std::pair< Status, Window > validate_and_configure_window(ITensorInfo *src, ITensorInfo *dst)
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.
TensorShape compute_prior_box_shape(const ITensorInfo &input, const PriorBoxLayerInfo &info)
Calculate the prior box output shape of a tensor.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
Describe one of the image's dimensions with a start, end and step.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
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.
virtual std::unique_ptr< T > clone() const =0
Provide a clone of the current object of class T.
size_t get_data_layout_dimension_index(const DataLayout &data_layout, const DataLayoutDimension &data_layout_dimension)
Get the index of the given dimension.
Describe a multidimensional execution window.
@ ELEMENTWISE
Elementwise CL kernel type.
#define ARM_COMPUTE_RETURN_ERROR_ON_MSG(cond, msg)
If the condition is true, an error is returned.
Copyright (c) 2017-2024 Arm Limited.
cl::NDRange lws_hint() const
Return the Local-Workgroup-Size hint.
#define ARM_COMPUTE_RETURN_ERROR_ON_NULLPTR(...)
Store the tensor's metadata.
@ F32
32-bit floating-point number
#define ARM_COMPUTE_CREATE_ERROR(error_code, msg)
Creates an error with a given message.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
unsigned int num_elems_processed_per_iteration
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
Window first_slice_window_2D() const
First 2D slice of the window.
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.