From fd627ffaec8fd8801d980b4c91ee7c0607ab6aaf Mon Sep 17 00:00:00 2001 From: Jan Eilers Date: Thu, 25 Feb 2021 17:44:00 +0000 Subject: IVGCVSW-5687 Update Doxygen Docu * Update Doxygen Documentation for 21.02 release Signed-off-by: Jan Eilers Change-Id: I9ed2f9caab038836ea99d7b378d7899fe431a4e5 --- 21.02/_tensor_test_8cpp.xhtml | 733 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 733 insertions(+) create mode 100644 21.02/_tensor_test_8cpp.xhtml (limited to '21.02/_tensor_test_8cpp.xhtml') diff --git a/21.02/_tensor_test_8cpp.xhtml b/21.02/_tensor_test_8cpp.xhtml new file mode 100644 index 0000000000..83250ec1d2 --- /dev/null +++ b/21.02/_tensor_test_8cpp.xhtml @@ -0,0 +1,733 @@ + + + + + + + + + + + + + +ArmNN: src/armnn/test/TensorTest.cpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  21.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
TensorTest.cpp File Reference
+
+
+
#include <boost/test/unit_test.hpp>
+#include <armnn/Tensor.hpp>
+#include <armnn/utility/IgnoreUnused.hpp>
+
+

Go to the source code of this file.

+ + + + + +

+Namespaces

 armnn
 Copyright (c) 2021 ARM Limited and Contributors.
 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

+Functions

std::ostream & boost_test_print_type (std::ostream &ostr, const TensorInfo &right)
 
std::ostream & boost_test_print_type (std::ostream &ostr, const TensorShape &shape)
 
 BOOST_FIXTURE_TEST_CASE (ConstructShapeUsingListInitialization, TensorInfoFixture)
 
 BOOST_FIXTURE_TEST_CASE (ConstructTensorInfo, TensorInfoFixture)
 
 BOOST_FIXTURE_TEST_CASE (CopyConstructTensorInfo, TensorInfoFixture)
 
 BOOST_FIXTURE_TEST_CASE (TensorInfoEquality, TensorInfoFixture)
 
 BOOST_FIXTURE_TEST_CASE (TensorInfoInequality, TensorInfoFixture)
 
 BOOST_FIXTURE_TEST_CASE (TensorInfoAssignmentOperator, TensorInfoFixture)
 
 BOOST_AUTO_TEST_CASE (CopyNoQuantizationTensorInfo)
 
 BOOST_AUTO_TEST_CASE (CopyDifferentQuantizationTensorInfo)
 
void CheckTensor (const ConstTensor &t)
 
 BOOST_AUTO_TEST_CASE (TensorVsConstTensor)
 
 BOOST_AUTO_TEST_CASE (ModifyTensorInfo)
 
 BOOST_AUTO_TEST_CASE (TensorShapeOperatorBrackets)
 
 BOOST_AUTO_TEST_CASE (TensorInfoPerAxisQuantization)
 
 BOOST_AUTO_TEST_CASE (TensorShape_scalar)
 
 BOOST_AUTO_TEST_CASE (TensorShape_DynamicTensorType1_unknownNumberDimensions)
 
 BOOST_AUTO_TEST_CASE (TensorShape_DynamicTensorType1_unknownAllDimensionsSizes)
 
 BOOST_AUTO_TEST_CASE (TensorShape_DynamicTensorType1_unknownSomeDimensionsSizes)
 
 BOOST_AUTO_TEST_CASE (TensorShape_DynamicTensorType1_transitionFromUnknownToKnownDimensionsSizes)
 
 BOOST_AUTO_TEST_CASE (Tensor_emptyConstructors)
 
+

Function Documentation

+ +

◆ BOOST_AUTO_TEST_CASE() [1/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (CopyNoQuantizationTensorInfo )
+
+ +

Definition at line 102 of file TensorTest.cpp.

+ +

References TensorInfo::GetDataType(), TensorInfo::GetQuantizationDim(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::GetShape(), OptionalBase::has_value(), armnn::QAsymmU8, TensorInfo::SetDataType(), TensorInfo::SetQuantizationDim(), TensorInfo::SetQuantizationOffset(), TensorInfo::SetQuantizationScale(), TensorInfo::SetShape(), and OptionalReferenceSwitch< IsReference, T >::value().

+
103 {
104  TensorInfo infoA;
105  infoA.SetShape({ 5, 6, 7, 8 });
106  infoA.SetDataType(DataType::QAsymmU8);
107 
108  TensorInfo infoB;
109  infoB.SetShape({ 5, 6, 7, 8 });
110  infoB.SetDataType(DataType::QAsymmU8);
111  infoB.SetQuantizationScale(10.0f);
112  infoB.SetQuantizationOffset(5);
114 
115  BOOST_TEST((infoA.GetShape() == TensorShape({ 5, 6, 7, 8 })));
116  BOOST_TEST((infoA.GetDataType() == DataType::QAsymmU8));
117  BOOST_TEST(infoA.GetQuantizationScale() == 1);
118  BOOST_TEST(infoA.GetQuantizationOffset() == 0);
119  BOOST_CHECK(!infoA.GetQuantizationDim().has_value());
120 
121  BOOST_TEST(infoA != infoB);
122  infoA = infoB;
123  BOOST_TEST(infoA == infoB);
124 
125  BOOST_TEST((infoA.GetShape() == TensorShape({ 5, 6, 7, 8 })));
126  BOOST_TEST((infoA.GetDataType() == DataType::QAsymmU8));
127  BOOST_TEST(infoA.GetQuantizationScale() == 10.0f);
128  BOOST_TEST(infoA.GetQuantizationOffset() == 5);
129  BOOST_CHECK(infoA.GetQuantizationDim().value() == 1);
130 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
+ + +
Optional< unsigned int > GetQuantizationDim() const
Definition: Tensor.cpp:485
+ + +
void SetShape(const TensorShape &newShape)
Definition: Tensor.hpp:189
+
int32_t GetQuantizationOffset() const
Definition: Tensor.cpp:469
+
float GetQuantizationScale() const
Definition: Tensor.cpp:452
+
DataType GetDataType() const
Definition: Tensor.hpp:194
+
bool has_value() const noexcept
Definition: Optional.hpp:53
+
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:464
+
void SetDataType(DataType type)
Definition: Tensor.hpp:195
+
void SetQuantizationDim(const Optional< unsigned int > &quantizationDim)
Definition: Tensor.cpp:490
+
void SetQuantizationOffset(int32_t offset)
Definition: Tensor.cpp:480
+
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [2/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (CopyDifferentQuantizationTensorInfo )
+
+ +

Definition at line 132 of file TensorTest.cpp.

+ +

References TensorInfo::GetDataType(), TensorInfo::GetQuantizationDim(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::GetShape(), armnn::QAsymmU8, TensorInfo::SetDataType(), TensorInfo::SetQuantizationDim(), TensorInfo::SetQuantizationOffset(), TensorInfo::SetQuantizationScale(), TensorInfo::SetShape(), and OptionalReferenceSwitch< IsReference, T >::value().

+
133 {
134  TensorInfo infoA;
135  infoA.SetShape({ 5, 6, 7, 8 });
136  infoA.SetDataType(DataType::QAsymmU8);
137  infoA.SetQuantizationScale(10.0f);
138  infoA.SetQuantizationOffset(5);
140 
141  TensorInfo infoB;
142  infoB.SetShape({ 5, 6, 7, 8 });
143  infoB.SetDataType(DataType::QAsymmU8);
144  infoB.SetQuantizationScale(11.0f);
145  infoB.SetQuantizationOffset(6);
147 
148  BOOST_TEST((infoA.GetShape() == TensorShape({ 5, 6, 7, 8 })));
149  BOOST_TEST((infoA.GetDataType() == DataType::QAsymmU8));
150  BOOST_TEST(infoA.GetQuantizationScale() == 10.0f);
151  BOOST_TEST(infoA.GetQuantizationOffset() == 5);
152  BOOST_CHECK(infoA.GetQuantizationDim().value() == 1);
153 
154  BOOST_TEST(infoA != infoB);
155  infoA = infoB;
156  BOOST_TEST(infoA == infoB);
157 
158  BOOST_TEST((infoA.GetShape() == TensorShape({ 5, 6, 7, 8 })));
159  BOOST_TEST((infoA.GetDataType() == DataType::QAsymmU8));
160  BOOST_TEST(infoA.GetQuantizationScale() == 11.0f);
161  BOOST_TEST(infoA.GetQuantizationOffset() == 6);
162  BOOST_CHECK(infoA.GetQuantizationDim().value() == 2);
163 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
+ + +
Optional< unsigned int > GetQuantizationDim() const
Definition: Tensor.cpp:485
+ + +
void SetShape(const TensorShape &newShape)
Definition: Tensor.hpp:189
+
int32_t GetQuantizationOffset() const
Definition: Tensor.cpp:469
+
float GetQuantizationScale() const
Definition: Tensor.cpp:452
+
DataType GetDataType() const
Definition: Tensor.hpp:194
+
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:464
+
void SetDataType(DataType type)
Definition: Tensor.hpp:195
+
void SetQuantizationDim(const Optional< unsigned int > &quantizationDim)
Definition: Tensor.cpp:490
+
void SetQuantizationOffset(int32_t offset)
Definition: Tensor.cpp:480
+
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [3/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (TensorVsConstTensor )
+
+ +

Definition at line 170 of file TensorTest.cpp.

+ +

References CheckTensor().

+
171 {
172  int mutableDatum = 2;
173  const int immutableDatum = 3;
174 
175  armnn::Tensor uninitializedTensor;
176  armnn::ConstTensor uninitializedTensor2;
177 
178  uninitializedTensor2 = uninitializedTensor;
179 
180  armnn::Tensor t(TensorInfo(), &mutableDatum);
181  armnn::ConstTensor ct(TensorInfo(), &immutableDatum);
182 
183  // Checks that both Tensor and ConstTensor can be passed as a ConstTensor.
184  CheckTensor(t);
185  CheckTensor(ct);
186 }
+
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:306
+
void CheckTensor(const ConstTensor &t)
Definition: TensorTest.cpp:165
+
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
+
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [4/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (ModifyTensorInfo )
+
+ +

Definition at line 188 of file TensorTest.cpp.

+ +

References TensorInfo::GetDataType(), TensorInfo::GetQuantizationOffset(), TensorInfo::GetQuantizationScale(), TensorInfo::GetShape(), armnn::info, armnn::QAsymmU8, TensorInfo::SetDataType(), TensorInfo::SetQuantizationOffset(), TensorInfo::SetQuantizationScale(), and TensorInfo::SetShape().

+
189 {
191  info.SetShape({ 5, 6, 7, 8 });
192  BOOST_TEST((info.GetShape() == TensorShape({ 5, 6, 7, 8 })));
193  info.SetDataType(DataType::QAsymmU8);
194  BOOST_TEST((info.GetDataType() == DataType::QAsymmU8));
195  info.SetQuantizationScale(10.0f);
196  BOOST_TEST(info.GetQuantizationScale() == 10.0f);
197  info.SetQuantizationOffset(5);
198  BOOST_TEST(info.GetQuantizationOffset() == 5);
199 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
+ + +
void SetShape(const TensorShape &newShape)
Definition: Tensor.hpp:189
+
int32_t GetQuantizationOffset() const
Definition: Tensor.cpp:469
+
float GetQuantizationScale() const
Definition: Tensor.cpp:452
+
DataType GetDataType() const
Definition: Tensor.hpp:194
+
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:464
+
void SetDataType(DataType type)
Definition: Tensor.hpp:195
+ +
void SetQuantizationOffset(int32_t offset)
Definition: Tensor.cpp:480
+
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [5/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (TensorShapeOperatorBrackets )
+
+ +

Definition at line 201 of file TensorTest.cpp.

+
202 {
203  const TensorShape constShape({0,1,2,3});
204  TensorShape shape({0,1,2,3});
205 
206  // Checks version of operator[] which returns an unsigned int.
207  BOOST_TEST(shape[2] == 2);
208  shape[2] = 20;
209  BOOST_TEST(shape[2] == 20);
210 
211  // Checks the version of operator[] which returns a reference.
212  BOOST_TEST(constShape[2] == 2);
213 }
+
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [6/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (TensorInfoPerAxisQuantization )
+
+ +

Definition at line 215 of file TensorTest.cpp.

+ +

References armnn::Float32, and TensorInfo::SetQuantizationScales().

+
216 {
217  // Old constructor
218  TensorInfo tensorInfo0({ 1, 1 }, DataType::Float32, 2.0f, 1);
219  BOOST_CHECK(!tensorInfo0.HasMultipleQuantizationScales());
220  BOOST_CHECK(tensorInfo0.GetQuantizationScale() == 2.0f);
221  BOOST_CHECK(tensorInfo0.GetQuantizationOffset() == 1);
222  BOOST_CHECK(tensorInfo0.GetQuantizationScales()[0] == 2.0f);
223  BOOST_CHECK(!tensorInfo0.GetQuantizationDim().has_value());
224 
225  // Set per-axis quantization scales
226  std::vector<float> perAxisScales{ 3.0f, 4.0f };
227  tensorInfo0.SetQuantizationScales(perAxisScales);
228  BOOST_CHECK(tensorInfo0.HasMultipleQuantizationScales());
229  BOOST_CHECK(tensorInfo0.GetQuantizationScales() == perAxisScales);
230 
231  // Set per-tensor quantization scale
232  tensorInfo0.SetQuantizationScale(5.0f);
233  BOOST_CHECK(!tensorInfo0.HasMultipleQuantizationScales());
234  BOOST_CHECK(tensorInfo0.GetQuantizationScales()[0] == 5.0f);
235 
236  // Set quantization offset
237  tensorInfo0.SetQuantizationDim(Optional<unsigned int>(1));
238  BOOST_CHECK(tensorInfo0.GetQuantizationDim().value() == 1);
239 
240  // New constructor
241  perAxisScales = { 6.0f, 7.0f };
242  TensorInfo tensorInfo1({ 1, 1 }, DataType::Float32, perAxisScales, 1);
243  BOOST_CHECK(tensorInfo1.HasMultipleQuantizationScales());
244  BOOST_CHECK(tensorInfo1.GetQuantizationOffset() == 0);
245  BOOST_CHECK(tensorInfo1.GetQuantizationScales() == perAxisScales);
246  BOOST_CHECK(tensorInfo1.GetQuantizationDim().value() == 1);
247 }
+ +
void SetQuantizationScales(const std::vector< float > &scales)
Definition: Tensor.cpp:447
+
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [7/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (TensorShape_scalar )
+
+ +

Definition at line 249 of file TensorTest.cpp.

+ +

References TensorShape::AreAllDimensionsSpecified(), armnn::Float32, TensorShape::GetDimensionality(), TensorShape::GetDimensionSpecificity(), BaseTensor< MemoryType >::GetInfo(), BaseTensor< MemoryType >::GetMemoryArea(), TensorShape::GetNumDimensions(), TensorShape::GetNumElements(), TensorInfo::GetShape(), BaseTensor< MemoryType >::GetShape(), armnn::info, TensorShape::IsAtLeastOneDimensionSpecified(), and armnn::Scalar.

+
250 {
251  float mutableDatum = 3.1416f;
252 
254  armnn::TensorInfo info ( shape, DataType::Float32 );
255  const armnn::Tensor tensor ( info, &mutableDatum );
256 
257  BOOST_CHECK(armnn::Dimensionality::Scalar == shape.GetDimensionality());
258  float scalarValue = *reinterpret_cast<float*>(tensor.GetMemoryArea());
259  BOOST_CHECK_MESSAGE(mutableDatum == scalarValue, "Scalar value is " << scalarValue);
260 
261  armnn::TensorShape shape_equal;
262  armnn::TensorShape shape_different;
263  shape_equal = shape;
264  BOOST_TEST(shape_equal == shape);
265  BOOST_TEST(shape_different != shape);
266  BOOST_CHECK_MESSAGE(1 == shape.GetNumElements(), "Number of elements is " << shape.GetNumElements());
267  BOOST_CHECK_MESSAGE(1 == shape.GetNumDimensions(), "Number of dimensions is " << shape.GetNumDimensions());
268  BOOST_CHECK(true == shape.GetDimensionSpecificity(0));
269  BOOST_CHECK(shape.AreAllDimensionsSpecified());
270  BOOST_CHECK(shape.IsAtLeastOneDimensionSpecified());
271 
272  BOOST_TEST(1 == shape[0]);
273  BOOST_TEST(1 == tensor.GetShape()[0]);
274  BOOST_TEST(1 == tensor.GetInfo().GetShape()[0]);
275  BOOST_CHECK_THROW( shape[1], InvalidArgumentException );
276 
277  float newMutableDatum = 42.f;
278  std::memcpy(tensor.GetMemoryArea(), &newMutableDatum, sizeof(float));
279  scalarValue = *reinterpret_cast<float*>(tensor.GetMemoryArea());
280  BOOST_CHECK_MESSAGE(newMutableDatum == scalarValue, "Scalar value is " << scalarValue);
281 }
+ +
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:306
+ + + +
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [8/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (TensorShape_DynamicTensorType1_unknownNumberDimensions )
+
+ +

Definition at line 283 of file TensorTest.cpp.

+ +

References armnn::Float32, TensorShape::GetDimensionality(), TensorShape::GetNumDimensions(), TensorShape::GetNumElements(), armnn::info, and armnn::NotSpecified.

+
284 {
285  float mutableDatum = 3.1416f;
286 
288  armnn::TensorInfo info ( shape, DataType::Float32 );
289  armnn::Tensor tensor ( info, &mutableDatum );
290 
291  BOOST_CHECK(armnn::Dimensionality::NotSpecified == shape.GetDimensionality());
292  BOOST_CHECK_THROW( shape[0], InvalidArgumentException );
293  BOOST_CHECK_THROW( shape.GetNumElements(), InvalidArgumentException );
294  BOOST_CHECK_THROW( shape.GetNumDimensions(), InvalidArgumentException );
295 
296  armnn::TensorShape shape_equal;
297  armnn::TensorShape shape_different;
298  shape_equal = shape;
299  BOOST_TEST(shape_equal == shape);
300  BOOST_TEST(shape_different != shape);
301 }
+ + +
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:306
+ + +
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [9/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (TensorShape_DynamicTensorType1_unknownAllDimensionsSizes )
+
+ +

Definition at line 303 of file TensorTest.cpp.

+ +

References TensorShape::AreAllDimensionsSpecified(), armnn::Float32, TensorShape::GetDimensionality(), TensorShape::GetDimensionSpecificity(), TensorShape::GetNumDimensions(), TensorShape::GetNumElements(), armnn::info, TensorShape::IsAtLeastOneDimensionSpecified(), and armnn::Specified.

+
304 {
305  float mutableDatum = 3.1416f;
306 
307  armnn::TensorShape shape ( 3, false );
308  armnn::TensorInfo info ( shape, DataType::Float32 );
309  armnn::Tensor tensor ( info, &mutableDatum );
310 
311  BOOST_CHECK(armnn::Dimensionality::Specified == shape.GetDimensionality());
312  BOOST_CHECK_MESSAGE(0 == shape.GetNumElements(), "Number of elements is " << shape.GetNumElements());
313  BOOST_CHECK_MESSAGE(3 == shape.GetNumDimensions(), "Number of dimensions is " << shape.GetNumDimensions());
314  BOOST_CHECK(false == shape.GetDimensionSpecificity(0));
315  BOOST_CHECK(false == shape.GetDimensionSpecificity(1));
316  BOOST_CHECK(false == shape.GetDimensionSpecificity(2));
317  BOOST_CHECK(!shape.AreAllDimensionsSpecified());
318  BOOST_CHECK(!shape.IsAtLeastOneDimensionSpecified());
319 
320  armnn::TensorShape shape_equal;
321  armnn::TensorShape shape_different;
322  shape_equal = shape;
323  BOOST_TEST(shape_equal == shape);
324  BOOST_TEST(shape_different != shape);
325 }
+ + +
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:306
+ +
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [10/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (TensorShape_DynamicTensorType1_unknownSomeDimensionsSizes )
+
+ +

Definition at line 327 of file TensorTest.cpp.

+ +

References armnn::Float32, BaseTensor< MemoryType >::GetInfo(), TensorInfo::GetShape(), BaseTensor< MemoryType >::GetShape(), armnn::info, and armnn::Specified.

+
328 {
329  std::vector<float> mutableDatum { 42.f, 42.f, 42.f,
330  0.0f, 0.1f, 0.2f };
331 
332  armnn::TensorShape shape ( {2, 0, 3}, {true, false, true} );
333  armnn::TensorInfo info ( shape, DataType::Float32 );
334  armnn::Tensor tensor ( info, &mutableDatum );
335 
336  BOOST_CHECK(armnn::Dimensionality::Specified == shape.GetDimensionality());
337  BOOST_CHECK_MESSAGE(6 == shape.GetNumElements(), "Number of elements is " << shape.GetNumElements());
338  BOOST_CHECK_MESSAGE(3 == shape.GetNumDimensions(), "Number of dimensions is " << shape.GetNumDimensions());
339  BOOST_CHECK(true == shape.GetDimensionSpecificity(0));
340  BOOST_CHECK(false == shape.GetDimensionSpecificity(1));
341  BOOST_CHECK(true == shape.GetDimensionSpecificity(2));
342  BOOST_CHECK(!shape.AreAllDimensionsSpecified());
343  BOOST_CHECK(shape.IsAtLeastOneDimensionSpecified());
344 
345  BOOST_CHECK_THROW(shape[1], InvalidArgumentException);
346  BOOST_CHECK_THROW(tensor.GetShape()[1], InvalidArgumentException);
347  BOOST_CHECK_THROW(tensor.GetInfo().GetShape()[1], InvalidArgumentException);
348 
349  BOOST_TEST(2 == shape[0]);
350  BOOST_TEST(2 == tensor.GetShape()[0]);
351  BOOST_TEST(2 == tensor.GetInfo().GetShape()[0]);
352  BOOST_CHECK_THROW( shape[1], InvalidArgumentException );
353 
354  BOOST_TEST(3 == shape[2]);
355  BOOST_TEST(3 == tensor.GetShape()[2]);
356  BOOST_TEST(3 == tensor.GetInfo().GetShape()[2]);
357 
358  armnn::TensorShape shape_equal;
359  armnn::TensorShape shape_different;
360  shape_equal = shape;
361  BOOST_TEST(shape_equal == shape);
362  BOOST_TEST(shape_different != shape);
363 }
+ + +
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:306
+ + +
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [11/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (TensorShape_DynamicTensorType1_transitionFromUnknownToKnownDimensionsSizes )
+
+ +

Definition at line 365 of file TensorTest.cpp.

+ +

References TensorShape::AreAllDimensionsSpecified(), armnn::Float32, TensorShape::GetDimensionality(), TensorShape::GetDimensionSpecificity(), BaseTensor< MemoryType >::GetInfo(), TensorShape::GetNumDimensions(), TensorShape::GetNumElements(), TensorInfo::GetShape(), BaseTensor< MemoryType >::GetShape(), armnn::info, TensorShape::IsAtLeastOneDimensionSpecified(), armnn::NotSpecified, TensorShape::SetDimensionSize(), TensorShape::SetNumDimensions(), TensorInfo::SetShape(), and armnn::Specified.

+
366 {
367  std::vector<float> mutableDatum { 42.f, 42.f, 42.f,
368  0.0f, 0.1f, 0.2f };
369 
371  armnn::TensorInfo info ( shape, DataType::Float32 );
372  armnn::Tensor tensor ( info, &mutableDatum );
373 
374  // Specify the number of dimensions
375  shape.SetNumDimensions(3);
376  BOOST_CHECK(armnn::Dimensionality::Specified == shape.GetDimensionality());
377  BOOST_CHECK_MESSAGE(3 == shape.GetNumDimensions(), "Number of dimensions is " << shape.GetNumDimensions());
378  BOOST_CHECK(false == shape.GetDimensionSpecificity(0));
379  BOOST_CHECK(false == shape.GetDimensionSpecificity(1));
380  BOOST_CHECK(false == shape.GetDimensionSpecificity(2));
381  BOOST_CHECK(!shape.AreAllDimensionsSpecified());
382  BOOST_CHECK(!shape.IsAtLeastOneDimensionSpecified());
383 
384  // Specify dimension 0 and 2.
385  shape.SetDimensionSize(0, 2);
386  shape.SetDimensionSize(2, 3);
387  BOOST_CHECK_MESSAGE(3 == shape.GetNumDimensions(), "Number of dimensions is " << shape.GetNumDimensions());
388  BOOST_CHECK_MESSAGE(6 == shape.GetNumElements(), "Number of elements is " << shape.GetNumElements());
389  BOOST_CHECK(true == shape.GetDimensionSpecificity(0));
390  BOOST_CHECK(false == shape.GetDimensionSpecificity(1));
391  BOOST_CHECK(true == shape.GetDimensionSpecificity(2));
392  BOOST_CHECK(!shape.AreAllDimensionsSpecified());
393  BOOST_CHECK(shape.IsAtLeastOneDimensionSpecified());
394 
395  info.SetShape(shape);
396  armnn::Tensor tensor2( info, &mutableDatum );
397  BOOST_TEST(2 == shape[0]);
398  BOOST_TEST(2 == tensor2.GetShape()[0]);
399  BOOST_TEST(2 == tensor2.GetInfo().GetShape()[0]);
400 
401  BOOST_CHECK_THROW(shape[1], InvalidArgumentException);
402  BOOST_CHECK_THROW(tensor.GetShape()[1], InvalidArgumentException);
403  BOOST_CHECK_THROW(tensor.GetInfo().GetShape()[1], InvalidArgumentException);
404 
405  BOOST_TEST(3 == shape[2]);
406  BOOST_TEST(3 == tensor2.GetShape()[2]);
407  BOOST_TEST(3 == tensor2.GetInfo().GetShape()[2]);
408 
409  armnn::TensorShape shape_equal;
410  armnn::TensorShape shape_different;
411  shape_equal = shape;
412  BOOST_TEST(shape_equal == shape);
413  BOOST_TEST(shape_different != shape);
414 
415  // Specify dimension 1.
416  shape.SetDimensionSize(1, 5);
417  BOOST_CHECK_MESSAGE(3 == shape.GetNumDimensions(), "Number of dimensions is " << shape.GetNumDimensions());
418  BOOST_CHECK_MESSAGE(30 == shape.GetNumElements(), "Number of elements is " << shape.GetNumElements());
419  BOOST_CHECK(true == shape.GetDimensionSpecificity(0));
420  BOOST_CHECK(true == shape.GetDimensionSpecificity(1));
421  BOOST_CHECK(true == shape.GetDimensionSpecificity(2));
422  BOOST_CHECK(shape.AreAllDimensionsSpecified());
423  BOOST_CHECK(shape.IsAtLeastOneDimensionSpecified());
424 }
+ + + +
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:306
+ + +
+
+
+ +

◆ BOOST_AUTO_TEST_CASE() [12/12]

+ +
+
+ + + + + + + + +
BOOST_AUTO_TEST_CASE (Tensor_emptyConstructors )
+
+ +

Definition at line 426 of file TensorTest.cpp.

+ +

References BOOST_AUTO_TEST_SUITE_END(), and armnn::Specified.

+
427 {
428  auto shape = armnn::TensorShape();
429  BOOST_CHECK_MESSAGE( 0 == shape.GetNumDimensions(), "Number of dimensions is " << shape.GetNumDimensions());
430  BOOST_CHECK_MESSAGE( 0 == shape.GetNumElements(), "Number of elements is " << shape.GetNumElements());
431  BOOST_CHECK( armnn::Dimensionality::Specified == shape.GetDimensionality());
432  BOOST_CHECK( shape.AreAllDimensionsSpecified());
433  BOOST_CHECK_THROW( shape[0], InvalidArgumentException );
434 
435  auto tensor = armnn::Tensor();
436  BOOST_CHECK_MESSAGE( 0 == tensor.GetNumDimensions(), "Number of dimensions is " << tensor.GetNumDimensions());
437  BOOST_CHECK_MESSAGE( 0 == tensor.GetNumElements(), "Number of elements is " << tensor.GetNumElements());
438  BOOST_CHECK_MESSAGE( 0 == tensor.GetShape().GetNumDimensions(), "Number of dimensions is " <<
439  tensor.GetShape().GetNumDimensions());
440  BOOST_CHECK_MESSAGE( 0 == tensor.GetShape().GetNumElements(), "Number of dimensions is " <<
441  tensor.GetShape().GetNumElements());
442  BOOST_CHECK( armnn::Dimensionality::Specified == tensor.GetShape().GetDimensionality());
443  BOOST_CHECK( tensor.GetShape().AreAllDimensionsSpecified());
444  BOOST_CHECK_THROW( tensor.GetShape()[0], InvalidArgumentException );
445 }
+ +
A tensor defined by a TensorInfo (shape and data type) and a mutable backing store.
Definition: Tensor.hpp:306
+ +
+
+
+ +

◆ BOOST_FIXTURE_TEST_CASE() [1/6]

+ +
+
+ + + + + + + + + + + + + + + + + + +
BOOST_FIXTURE_TEST_CASE (ConstructShapeUsingListInitialization ,
TensorInfoFixture  
)
+
+ +

Definition at line 55 of file TensorTest.cpp.

+
56 {
57  TensorShape listInitializedShape{ 6, 7, 8, 9 };
58  BOOST_TEST(listInitializedShape == m_TensorInfo.GetShape());
59 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
+ +
+
+
+ +

◆ BOOST_FIXTURE_TEST_CASE() [2/6]

+ +
+
+ + + + + + + + + + + + + + + + + + +
BOOST_FIXTURE_TEST_CASE (ConstructTensorInfo ,
TensorInfoFixture  
)
+
+ +

Definition at line 61 of file TensorTest.cpp.

+
62 {
63  BOOST_TEST(m_TensorInfo.GetNumDimensions() == 4);
64  BOOST_TEST(m_TensorInfo.GetShape()[0] == 6); // <= Outer most
65  BOOST_TEST(m_TensorInfo.GetShape()[1] == 7);
66  BOOST_TEST(m_TensorInfo.GetShape()[2] == 8);
67  BOOST_TEST(m_TensorInfo.GetShape()[3] == 9); // <= Inner most
68 }
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
+
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:191
+
+
+
+ +

◆ BOOST_FIXTURE_TEST_CASE() [3/6]

+ +
+
+ + + + + + + + + + + + + + + + + + +
BOOST_FIXTURE_TEST_CASE (CopyConstructTensorInfo ,
TensorInfoFixture  
)
+
+ +

Definition at line 70 of file TensorTest.cpp.

+
71 {
72  TensorInfo copyConstructed(m_TensorInfo);
73  BOOST_TEST(copyConstructed.GetNumDimensions() == 4);
74  BOOST_TEST(copyConstructed.GetShape()[0] == 6);
75  BOOST_TEST(copyConstructed.GetShape()[1] == 7);
76  BOOST_TEST(copyConstructed.GetShape()[2] == 8);
77  BOOST_TEST(copyConstructed.GetShape()[3] == 9);
78 }
+
+
+
+ +

◆ BOOST_FIXTURE_TEST_CASE() [4/6]

+ +
+
+ + + + + + + + + + + + + + + + + + +
BOOST_FIXTURE_TEST_CASE (TensorInfoEquality ,
TensorInfoFixture  
)
+
+ +

Definition at line 80 of file TensorTest.cpp.

+
81 {
82  TensorInfo copyConstructed(m_TensorInfo);
83  BOOST_TEST(copyConstructed == m_TensorInfo);
84 }
+
+
+
+ +

◆ BOOST_FIXTURE_TEST_CASE() [5/6]

+ +
+
+ + + + + + + + + + + + + + + + + + +
BOOST_FIXTURE_TEST_CASE (TensorInfoInequality ,
TensorInfoFixture  
)
+
+ +

Definition at line 86 of file TensorTest.cpp.

+ +

References armnn::Float32.

+
87 {
88  TensorInfo other;
89  unsigned int sizes[] = {2,3,4,5};
90  other = TensorInfo(4, sizes, DataType::Float32);
91 
92  BOOST_TEST(other != m_TensorInfo);
93 }
+
+
+
+ +

◆ BOOST_FIXTURE_TEST_CASE() [6/6]

+ +
+
+ + + + + + + + + + + + + + + + + + +
BOOST_FIXTURE_TEST_CASE (TensorInfoAssignmentOperator ,
TensorInfoFixture  
)
+
+ +

Definition at line 95 of file TensorTest.cpp.

+
96 {
97  TensorInfo copy;
98  copy = m_TensorInfo;
99  BOOST_TEST(copy == m_TensorInfo);
100 }
+
+
+
+ +

◆ CheckTensor()

+ +
+
+ + + + + + + + +
void CheckTensor (const ConstTensort)
+
+ +

Definition at line 165 of file TensorTest.cpp.

+ +

References BaseTensor< MemoryType >::GetInfo().

+ +

Referenced by BOOST_AUTO_TEST_CASE().

+
166 {
167  t.GetInfo();
168 }
const TensorInfo & GetInfo() const
Definition: Tensor.hpp:282
+
+
+
+
+
+ + + + -- cgit v1.2.1