Compute Library
 21.02
NEHistogram.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2020 Arm Limited.
3  *
4  * SPDX-License-Identifier: MIT
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy
7  * of this software and associated documentation files (the "Software"), to
8  * deal in the Software without restriction, including without limitation the
9  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10  * sell copies of the Software, and to permit persons to whom the Software is
11  * furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included in all
14  * copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  * SOFTWARE.
23  */
25 
26 #include "arm_compute/core/Error.h"
33 
34 namespace arm_compute
35 {
36 NEHistogram::~NEHistogram() = default;
37 
39  : _histogram_kernel(), _local_hist(), _window_lut(window_lut_default_size), _local_hist_size(0)
40 {
41 }
42 
44 {
46  ARM_COMPUTE_ERROR_ON(nullptr == output);
47 
48  // Allocate space for threads local histograms
49  _local_hist_size = output->num_bins() * NEScheduler::get().num_threads();
50  _local_hist.resize(_local_hist_size);
51 
52  // Configure kernel
53  _histogram_kernel = std::make_unique<NEHistogramKernel>();
54  _histogram_kernel->configure(input, output, _local_hist.data(), _window_lut.data());
55 }
56 
58 {
59  // Calculate histogram of input.
60  NEScheduler::get().schedule(_histogram_kernel.get(), Window::DimY);
61 }
62 } // namespace arm_compute
NEHistogram()
Default Constructor.
Definition: NEHistogram.cpp:38
#define ARM_COMPUTE_ERROR_ON_TENSOR_NOT_2D(t)
Definition: Validate.h:856
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Definition: Error.h:466
Interface for Neon tensor.
Definition: ITensor.h:36
void configure(const IImage *input, IDistribution1D *output)
Initialise the kernel&#39;s inputs.
Definition: NEHistogram.cpp:43
Copyright (c) 2017-2021 Arm Limited.
1D Distribution interface
void run() override
Run the kernels contained in the function.
Definition: NEHistogram.cpp:57
~NEHistogram()
Default destructor.
size_t num_bins() const
Returns the number of bins that the distribution has.
static constexpr size_t DimY
Alias for dimension 1 also known as Y dimension.
Definition: Window.h:45
virtual void schedule(ICPPKernel *kernel, const Hints &hints)=0
Runs the kernel in the same thread as the caller synchronously.
virtual unsigned int num_threads() const =0
Returns the number of threads that the SingleThreadScheduler has in his pool.
static IScheduler & get()
Access the scheduler singleton.
Definition: Scheduler.cpp:94