48 : _input(nullptr), _output(nullptr)
79 unsigned int num_bins = _output->
num_bins();
80 unsigned int window_size = _output->
window();
83 unsigned int offrange = offset +
range;
84 unsigned int bin_size = _output->
size();
85 unsigned int buffer_size = bin_size + 1;
88 bool is_fixed_size = (256 == num_bins) && (1 == window_size) && (0 ==
offset) && (256 == offrange);
89 const std::string
kernel_name = is_fixed_size ?
"hist_local_kernel_fixed" :
"hist_local_kernel";
94 _kernel.setArg(idx++, buffer_size,
nullptr);
95 _kernel.setArg(idx++, _output->
cl_buffer());
98 _kernel.setArg<cl_uint>(idx++, num_bins);
99 _kernel.setArg<cl_uint>(idx++,
offset);
100 _kernel.setArg<cl_uint>(idx++,
range);
101 _kernel.setArg<cl_uint>(idx++, offrange);
114 ICLKernel::configure_internal(win);
132 _output->
map(queue,
true);
134 memset(_output->
buffer(), 0, _output->
size());
135 _output->
unmap(queue);
143 const unsigned int gws_x = (window.
x().
end() - window.
x().
start()) / window.
x().
step();
149 unsigned int idx = 0;
152 enqueue(queue, *
this, slice, lws);
158 : _input(nullptr), _output(nullptr)
192 unsigned int num_bins = _output->
num_bins();
193 unsigned int window_size = _output->
window();
196 unsigned int offrange = offset +
range;
199 bool is_fixed_size = (256 == num_bins) && (1 == window_size) && (0 ==
offset) && (256 == offrange);
200 const std::string
kernel_name = is_fixed_size ?
"hist_border_kernel_fixed" :
"hist_border_kernel";
205 _kernel.setArg(idx++, _output->
cl_buffer());
208 _kernel.setArg<cl_uint>(idx++, num_bins);
209 _kernel.setArg<cl_uint>(idx++,
offset);
210 _kernel.setArg<cl_uint>(idx++,
range);
211 _kernel.setArg<cl_uint>(idx++, offrange);
219 ICLKernel::configure_internal(win);
240 cl::NDRange lws = cl::NDRange(1, 1);
247 unsigned int idx = 0;
250 enqueue(queue, *
this, slice, lws);
Window first_slice_window_2D() const
First 2D slice of the window.
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
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.
virtual size_t dimension(size_t index) const =0
Return the size of the requested dimension.
#define ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(t)
void configure(const ICLImage *input, ICLDistribution1D *output)
Initialise the kernel's input, output and border mode.
void unmap(cl::CommandQueue &q)
Enqueue an unmap operation of the allocated and mapped buffer on the given queue. ...
constexpr int step() const
Return the step of the dimension.
1 channel, 1 U8 per channel
std::string to_string(T &&value)
Convert integer and float values to string.
virtual DataType data_type() const =0
Data type used for each element of the tensor.
uint32_t range() const
Returns the range of the distribution.
#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.
uint32_t window() const
Returns the window of the distribution, which is the range divided by the number of bins...
Describe one of the image's dimensions with a start, end and step.
std::string lower_string(const std::string &val)
Lower a given string.
CLHistogramKernel()
Constructor.
bool slide_window_slice_2D(Window &slice) const
Slide the passed 2D window slice.
Copyright (c) 2017-2021 Arm Limited.
void map(cl::CommandQueue &q, bool blocking=true)
Enqueue a map operation of the allocated buffer on the given queue.
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.
const std::string & string_from_data_type(DataType dt)
Convert a data type identity into a string.
bool update_window_and_padding(Window &win, Ts &&... patterns)
Update window and padding size for each of the access patterns.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS(f, w)
SimpleTensor< T > range(SimpleTensor< T > &dst, float start, const size_t num_of_elements, float step)
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Implementation of a row access pattern.
virtual ITensorInfo * info() const =0
Interface to be implemented by the child class to return the tensor's metadata.
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.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
size_t num_bins() const
Returns the number of bins that the distribution has.
#define ARM_COMPUTE_ERROR_ON_DATA_TYPE_CHANNEL_NOT_IN(t, c,...)
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...
ICLDistribution1D interface class.
uint32_t * buffer() const override
Returns a pointer to the start of the distribution.
Interface for OpenCL tensor.
constexpr signed int pixels_per_item
virtual cl::Buffer & cl_buffer()=0
Interface to be implemented by the child class to return a reference to the OpenCL buffer containing ...
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
Manages all the OpenCL kernels compilation and caching, provides accessors for the OpenCL Context...
Wrapper to configure the Khronos OpenCL C++ header.
size_t size() const override
Returns the total size in bytes of the distribution.
void run(const Window &window, cl::CommandQueue &queue) override
Enqueue the OpenCL kernel to process the given window on the passed OpenCL command queue...
void configure(const ICLImage *input, ICLDistribution1D *output)
Initialise the kernel's input, output and border mode.
constexpr unsigned int local_x_size
CLHistogramBorderKernel()
Constructor.
constexpr int end() const
Return the end of the dimension.
constexpr int start() const
Return the start of the dimension.
Describe a multidimensional execution window.
int32_t offset() const
Returns the offset of the distribution.
SimpleTensor< T > slice(const SimpleTensor< T > &src, Coordinates starts, Coordinates ends)
constexpr const Dimension & x() const
Alias to access the first dimension of the window.