X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=documentation%2F_measurement_8h_source.xhtml;h=d534e0c689fd4fe9665f239e44a9b0e1632cb860;hb=HEAD;hp=e06cec1b674eb27a616617b7fb0c9507365a50e8;hpb=bf8b01dfbfdca124673ade33c5eac8f3748d7abd;p=platform%2Fupstream%2Farmcl.git diff --git a/documentation/_measurement_8h_source.xhtml b/documentation/_measurement_8h_source.xhtml index e06cec1..d534e0c 100644 --- a/documentation/_measurement_8h_source.xhtml +++ b/documentation/_measurement_8h_source.xhtml @@ -4,7 +4,7 @@ - + Compute Library: tests/framework/instruments/Measurement.h Source File @@ -12,22 +12,24 @@ + + + @@ -38,7 +40,7 @@
Compute Library -  17.10 +  18.05
@@ -46,7 +48,7 @@ - + @@ -101,7 +103,7 @@ $(document).ready(function(){initNavTree('_measurement_8h_source.xhtml','');}); onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()" onkeydown="return searchBox.OnSearchSelectKey(event)"> - All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages +
@@ -115,102 +117,42 @@ $(document).ready(function(){initNavTree('_measurement_8h_source.xhtml','');});
Measurement.h
-Go to the documentation of this file.
1 /*
-
2  * Copyright (c) 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  */
-
24 #ifndef ARM_COMPUTE_TEST_MEASUREMENT
-
25 #define ARM_COMPUTE_TEST_MEASUREMENT
-
26 
-
27 #include "../Utils.h"
-
28 
-
29 #include <ostream>
-
30 #include <string>
-
31 
-
32 namespace arm_compute
-
33 {
-
34 namespace test
-
35 {
-
36 namespace framework
-
37 {
- -
43 {
-
48  explicit IMeasurement(std::string unit)
-
49  : unit{ std::move(unit) }
-
50  {
-
51  }
-
52 
-
53  std::string unit;
-
54 };
-
55 
-
57 template <typename T>
- -
59 {
-
65  TypedMeasurement(T value, std::string unit)
-
66  : IMeasurement(std::move(unit)), value{ value }
-
67  {
-
68  }
-
69 
-
70  T value;
-
71 };
-
72 
-
77 template <typename T>
-
78 inline std::ostream &operator<<(std::ostream &os, const TypedMeasurement<T> &measurement)
-
79 {
-
80  os << measurement.value << measurement.unit;
-
81  return os;
-
82 }
-
83 
-
85 struct Measurement : public TypedMeasurement<double>
-
86 {
- -
88 
-
93  template <typename T>
- -
95  : Measurement(measurement.value, measurement.unit)
-
96  {
-
97  }
-
98 };
-
99 } // namespace framework
-
100 } // namespace test
-
101 } // namespace arm_compute
-
102 #endif /* ARM_COMPUTE_TEST_MEASUREMENT */
- -
Measurement of a specific type.
Definition: Measurement.h:58
- -
Generic measurement that stores values as double.
Definition: Measurement.h:85
- -
Measurement(TypedMeasurement< T > measurement)
Conversion constructor.
Definition: Measurement.h:94
-
TypedMeasurement(T value, std::string unit)
Constructor.
Definition: Measurement.h:65
-
IMeasurement(std::string unit)
Constructor.
Definition: Measurement.h:48
+Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017-2018 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  */
24 #ifndef ARM_COMPUTE_TEST_MEASUREMENT
25 #define ARM_COMPUTE_TEST_MEASUREMENT
26 
27 #include "../Utils.h"
28 #include "arm_compute/core/Error.h"
29 
30 #include <list>
31 #include <ostream>
32 #include <string>
33 
34 namespace arm_compute
35 {
36 namespace test
37 {
38 namespace framework
39 {
42 {
44  struct Value
45  {
50  Value(bool is_floating)
51  : v{ 0 }, is_floating_point(is_floating)
52  {
53  }
54 
57  friend std::ostream &operator<<(std::ostream &os, const Value &value)
58  {
59  if(value.is_floating_point)
60  {
61  os << arithmetic_to_string(value.v.floating_point, 4);
62  }
63  else
64  {
65  os << arithmetic_to_string(value.v.integer);
66  }
67  return os;
68  }
71  std::string to_string() const
72  {
73  std::stringstream ss;
74  ss << *this;
75  return ss.str();
76  }
84  {
86  {
87  b.v.floating_point += v.floating_point;
88  }
89  else
90  {
91  b.v.integer += v.integer;
92  }
93  return b;
94  }
95 
103  {
105  {
106  b.v.floating_point -= v.floating_point;
107  }
108  else
109  {
110  b.v.integer -= v.integer;
111  }
112  return b;
113  }
114 
122  {
124  {
125  b.v.floating_point *= v.floating_point;
126  }
127  else
128  {
129  b.v.integer *= v.integer;
130  }
131  return b;
132  }
133 
140  Value operator/(int b) const
141  {
144  {
145  res.v.floating_point = v.floating_point / b;
146  }
147  else
148  {
149  res.v.integer = v.integer / b;
150  }
151  return res;
152  }
153 
161  {
163  {
164  v.floating_point -= b.v.floating_point;
165  }
166  else
167  {
168  v.integer -= b.v.integer;
169  }
170  return *this;
171  }
172 
179  bool operator<(const Value &b) const
180  {
182  {
183  return v.floating_point < b.v.floating_point;
184  }
185  else
186  {
187  return v.integer < b.v.integer;
188  }
189  }
190 
198  static double relative_standard_deviation(const Value &variance, const Value &mean)
199  {
200  if(variance.is_floating_point)
201  {
202  return 100.0 * sqrt(variance.v.floating_point) / mean.v.floating_point;
203  }
204  else
205  {
206  return 100.0 * sqrt(static_cast<double>(variance.v.integer)) / mean.v.integer;
207  }
208  }
209 
211  union
212  {
214  long long int integer;
215  } v;
217  };
218 
225  bool operator<(const Measurement &b) const
226  {
227  return _value < b.value();
228  }
229 
239  friend inline std::ostream &operator<<(std::ostream &os, const Measurement &measurement)
240  {
241  os << measurement._value << " " << measurement._unit;
242  return os;
243  }
244 
251  template < typename Floating, typename std::enable_if < !std::is_integral<Floating>::value, int >::type = 0 >
252  Measurement(Floating v, std::string unit, std::list<std::string> raw = {})
253  : _unit(unit), _raw_data(std::move(raw)), _value(true)
254  {
255  _value.v.floating_point = static_cast<double>(v);
256  if(_raw_data.empty())
257  {
258  _raw_data = { _value.to_string() };
259  }
260  }
261 
268  template <typename Integer, typename std::enable_if<std::is_integral<Integer>::value, int>::type = 0>
269  Measurement(Integer v, std::string unit, std::list<std::string> raw = {})
270  : _unit(unit), _raw_data(std::move(raw)), _value(false)
271  {
272  _value.v.integer = static_cast<long long int>(v);
273  if(_raw_data.empty())
274  {
275  _raw_data = { _value.to_string() };
276  }
277  }
278 
283  const std::string &unit() const
284  {
285  return _unit;
286  }
287 
292  const std::list<std::string> &raw_data() const
293  {
294  return _raw_data;
295  }
296 
301  const Value &value() const
302  {
303  return _value;
304  }
305 
306 private:
307  std::string _unit;
308  std::list<std::string> _raw_data;
309  Value _value;
310 };
311 
312 } // namespace framework
313 } // namespace test
314 } // namespace arm_compute
315 #endif /* ARM_COMPUTE_TEST_MEASUREMENT */
Value operator+(Value b) const
Add with another value and return the sum.
Definition: Measurement.h:83
+ +
static double relative_standard_deviation(const Value &variance, const Value &mean)
Get the relative standard deviation to a given distribution as a percentage.
Definition: Measurement.h:198
+
const Value & value() const
Accessor for the stored value.
Definition: Measurement.h:301
+
Generic measurement that stores values as either double or long long int.
Definition: Measurement.h:41
+ +
This file contains all available output stages for GEMMLowp on OpenCL.
+
Value operator/(int b) const
Return the stored value divided by an integer.
Definition: Measurement.h:140
+
friend std::ostream & operator<<(std::ostream &os, const Measurement &measurement)
Stream output operator to print the measurement.
Definition: Measurement.h:239
+
Value & operator-=(const Value &b)
Subtract another value and return the updated stored value.
Definition: Measurement.h:160
+ +
union arm_compute::test::framework::Measurement::Value::@1 v
Stored value.
+ +
friend std::ostream & operator<<(std::ostream &os, const Value &value)
Add the value stored to the stream as a string.
Definition: Measurement.h:57
+
const std::list< std::string > & raw_data() const
Accessor for the raw data.
Definition: Measurement.h:292
+
bool is_floating_point
Is the stored value floating point or integer ?
Definition: Measurement.h:216
+
std::string to_string() const
Convert the value stored to string.
Definition: Measurement.h:71
+
Value operator-(Value b) const
Subtract with another value and return the result.
Definition: Measurement.h:102
+
Measurement(Floating v, std::string unit, std::list< std::string > raw={})
Constructor to store a floating point value.
Definition: Measurement.h:252
+
bool operator<(const Value &b) const
Compare the stored value with another value.
Definition: Measurement.h:179
+
bool operator<(const Measurement &b) const
Compare the stored value with another value.
Definition: Measurement.h:225
+ +
const std::string & unit() const
Accessor for the unit of the measurement.
Definition: Measurement.h:283
+
Value operator*(Value b) const
Multiple with another value and return the result.
Definition: Measurement.h:121
+
std::string arithmetic_to_string(T val, int decimal_places=0)
Create a string with the arithmetic value in full precision.
Definition: Utils.h:164
+
Measurement(Integer v, std::string unit, std::list< std::string > raw={})
Constructor to store an integer value.
Definition: Measurement.h:269
+
Value(bool is_floating)
Constructor.
Definition: Measurement.h:50