34 _min_max_count_vals(),
58 _min_max_vals = cl::Buffer(
CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, 2 *
sizeof(int32_t));
59 _min_max_count_vals = cl::Buffer(
CLScheduler::get().context(), CL_MEM_ALLOC_HOST_PTR | CL_MEM_READ_WRITE, 2 *
sizeof(uint32_t));
62 _min_count = min_count;
63 _max_count = max_count;
67 _min_max_kernel->configure(compile_context, input, &_min_max_vals);
68 _min_max_loc_kernel->configure(compile_context, input, &_min_max_vals, &_min_max_count_vals, _min_loc, _max_loc);
79 q.enqueueReadBuffer(_min_max_vals, CL_FALSE, 0 *
sizeof(int32_t),
sizeof(int32_t), static_cast<int32_t *>(_min));
80 q.enqueueReadBuffer(_min_max_vals, CL_FALSE, 1 *
sizeof(int32_t),
sizeof(int32_t), static_cast<int32_t *>(_max));
83 if(_min_count !=
nullptr)
85 q.enqueueReadBuffer(_min_max_count_vals, CL_FALSE, 0 *
sizeof(uint32_t),
sizeof(uint32_t), _min_count);
87 if(_max_count !=
nullptr)
89 q.enqueueReadBuffer(_min_max_count_vals, CL_FALSE, 1 *
sizeof(uint32_t),
sizeof(uint32_t), _max_count);
93 if(_min_loc !=
nullptr)
95 unsigned int min_count = 0;
96 q.enqueueReadBuffer(_min_max_count_vals, CL_TRUE, 0 *
sizeof(uint32_t),
sizeof(uint32_t), &min_count);
97 size_t min_corner_size = std::min(static_cast<size_t>(min_count), _min_loc->
max_num_values());
98 _min_loc->
resize(min_corner_size);
100 if(_max_loc !=
nullptr)
102 unsigned int max_count = 0;
103 q.enqueueReadBuffer(_min_max_count_vals, CL_TRUE, 1 *
sizeof(uint32_t),
sizeof(uint32_t), &max_count);
104 size_t max_corner_size = std::min(static_cast<size_t>(max_count), _max_loc->
max_num_values());
105 _max_loc->
resize(max_corner_size);
static CLScheduler & get()
Access the scheduler singleton.
void resize(size_t num)
Resizes the array to contain "num" elements.
void configure(const ICLImage *input, void *min, void *max, CLCoordinates2DArray *min_loc=nullptr, CLCoordinates2DArray *max_loc=nullptr, uint32_t *min_count=nullptr, uint32_t *max_count=nullptr)
Initialise the kernel's inputs and outputs.
#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.
Interface for the kernel to find min max locations of an image.
Copyright (c) 2017-2021 Arm Limited.
CLMinMaxLocation()
Constructor.
cl::CommandQueue & queue()
Accessor for the associated CL command queue.
Interface for the kernel to perform min max search on an image.
void enqueue(ICLKernel &kernel, bool flush=true)
Schedule the execution of the passed kernel if possible.
Interface for OpenCL tensor.
size_t max_num_values() const
Maximum number of values which can be stored in this array.
~CLMinMaxLocation()
Default destructor.
void run() override
Run the kernels contained in the function.