Compute Library
 21.02
IDistribution1D.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016, 2017 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"
27 
28 using namespace arm_compute;
29 
30 IDistribution1D::IDistribution1D(size_t num_bins, int32_t offset, uint32_t range)
31  : _num_bins(num_bins), _offset(offset), _range(range)
32 {
33  ARM_COMPUTE_ERROR_ON_MSG(0 == _num_bins, "Invalid number of bins, it should be greater than 0");
34 }
35 
37 {
38  return _num_bins;
39 }
40 
41 int32_t IDistribution1D::offset() const
42 {
43  return _offset;
44 }
45 
46 uint32_t IDistribution1D::range() const
47 {
48  return _range;
49 }
50 
51 uint32_t IDistribution1D::window() const
52 {
53  return _range / _num_bins;
54 }
55 
56 size_t IDistribution1D::size() const
57 {
58  return _num_bins * sizeof(uint32_t);
59 }
60 
62 {
63  _range = range;
64 }
65 
67 {
68  return 1;
69 }
__global uchar * offset(const Image *img, int x, int y)
Get the pointer position of a Image.
Definition: helpers.h:846
uint32_t range() const
Returns the range of the distribution.
size_t dimensions() const override
Returns the dimensions of the distribution.
uint32_t window() const
Returns the window of the distribution, which is the range divided by the number of bins...
Copyright (c) 2017-2021 Arm Limited.
SimpleTensor< T > range(SimpleTensor< T > &dst, float start, const size_t num_of_elements, float step)
Definition: Range.cpp:50
#define ARM_COMPUTE_ERROR_ON_MSG(cond, msg)
Definition: Error.h:456
IDistribution1D(size_t num_bins, int32_t offset, uint32_t range)
Constructor: Creates a 1D Distribution of a consecutive interval [offset, offset + range - 1] defined...
size_t num_bins() const
Returns the number of bins that the distribution has.
void set_range(uint32_t range)
Sets the range of the distribution.
size_t size() const override
Returns the total size in bytes of the distribution.
int32_t offset() const
Returns the offset of the distribution.