ArmNN
 21.05
TensorTest.cpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #include <boost/test/unit_test.hpp>
6 #include <armnn/Tensor.hpp>
8 
9 
10 namespace armnn
11 {
12 
13 // Adds unit test framework for interpreting TensorInfo type.
14 std::ostream& boost_test_print_type(std::ostream& ostr, const TensorInfo& right)
15 {
16  ostr << "TensorInfo[ "
17  << right.GetNumDimensions() << ","
18  << right.GetShape()[0] << ","
19  << right.GetShape()[1] << ","
20  << right.GetShape()[2] << ","
21  << right.GetShape()[3]
22  << " ]" << std::endl;
23  return ostr;
24 }
25 
26 std::ostream& boost_test_print_type(std::ostream& ostr, const TensorShape& shape)
27 {
28  ostr << "TensorShape[ "
29  << shape.GetNumDimensions() << ","
30  << shape[0] << ","
31  << shape[1] << ","
32  << shape[2] << ","
33  << shape[3]
34  << " ]" << std::endl;
35  return ostr;
36 }
37 
38 } //namespace armnn
39 using namespace armnn;
40 
42 
43 struct TensorInfoFixture
44 {
45  TensorInfoFixture()
46  {
47  unsigned int sizes[] = {6,7,8,9};
48  m_TensorInfo = TensorInfo(4, sizes, DataType::Float32);
49  }
50  ~TensorInfoFixture() {};
51 
52  TensorInfo m_TensorInfo;
53 };
54 
55 BOOST_FIXTURE_TEST_CASE(ConstructShapeUsingListInitialization, TensorInfoFixture)
56 {
57  TensorShape listInitializedShape{ 6, 7, 8, 9 };
58  BOOST_TEST(listInitializedShape == m_TensorInfo.GetShape());
59 }
60 
61 BOOST_FIXTURE_TEST_CASE(ConstructTensorInfo, TensorInfoFixture)
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 }
69 
70 BOOST_FIXTURE_TEST_CASE(CopyConstructTensorInfo, TensorInfoFixture)
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 }
79 
80 BOOST_FIXTURE_TEST_CASE(TensorInfoEquality, TensorInfoFixture)
81 {
82  TensorInfo copyConstructed(m_TensorInfo);
83  BOOST_TEST(copyConstructed == m_TensorInfo);
84 }
85 
86 BOOST_FIXTURE_TEST_CASE(TensorInfoInequality, TensorInfoFixture)
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 }
94 
95 BOOST_FIXTURE_TEST_CASE(TensorInfoAssignmentOperator, TensorInfoFixture)
96 {
97  TensorInfo copy;
98  copy = m_TensorInfo;
99  BOOST_TEST(copy == m_TensorInfo);
100 }
101 
102 BOOST_AUTO_TEST_CASE(CopyNoQuantizationTensorInfo)
103 {
104  TensorInfo infoA;
105  infoA.SetShape({ 5, 6, 7, 8 });
107 
108  TensorInfo infoB;
109  infoB.SetShape({ 5, 6, 7, 8 });
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 }
131 
132 BOOST_AUTO_TEST_CASE(CopyDifferentQuantizationTensorInfo)
133 {
134  TensorInfo infoA;
135  infoA.SetShape({ 5, 6, 7, 8 });
137  infoA.SetQuantizationScale(10.0f);
138  infoA.SetQuantizationOffset(5);
140 
141  TensorInfo infoB;
142  infoB.SetShape({ 5, 6, 7, 8 });
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 }
164 
165 void CheckTensor(const ConstTensor& t)
166 {
167  t.GetInfo();
168 }
169 
170 BOOST_AUTO_TEST_CASE(TensorVsConstTensor)
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 }
187 
188 BOOST_AUTO_TEST_CASE(ModifyTensorInfo)
189 {
191  info.SetShape({ 5, 6, 7, 8 });
192  BOOST_TEST((info.GetShape() == TensorShape({ 5, 6, 7, 8 })));
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 }
200 
201 BOOST_AUTO_TEST_CASE(TensorShapeOperatorBrackets)
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 }
214 
215 BOOST_AUTO_TEST_CASE(TensorInfoPerAxisQuantization)
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 }
248 
249 BOOST_AUTO_TEST_CASE(TensorShape_scalar)
250 {
251  float mutableDatum = 3.1416f;
252 
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 }
282 
283 BOOST_AUTO_TEST_CASE(TensorShape_DynamicTensorType1_unknownNumberDimensions)
284 {
285  float mutableDatum = 3.1416f;
286 
289  armnn::Tensor tensor ( info, &mutableDatum );
290 
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 }
302 
303 BOOST_AUTO_TEST_CASE(TensorShape_DynamicTensorType1_unknownAllDimensionsSizes)
304 {
305  float mutableDatum = 3.1416f;
306 
307  armnn::TensorShape shape ( 3, false );
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 }
326 
327 BOOST_AUTO_TEST_CASE(TensorShape_DynamicTensorType1_unknownSomeDimensionsSizes)
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} );
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 }
364 
365 BOOST_AUTO_TEST_CASE(TensorShape_DynamicTensorType1_transitionFromUnknownToKnownDimensionsSizes)
366 {
367  std::vector<float> mutableDatum { 42.f, 42.f, 42.f,
368  0.0f, 0.1f, 0.2f };
369 
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 }
425 
426 BOOST_AUTO_TEST_CASE(Tensor_emptyConstructors)
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 }
unsigned int GetNumElements() const
Function that calculates the tensor elements by multiplying all dimension size which are Specified...
Definition: Tensor.cpp:181
BOOST_AUTO_TEST_SUITE(TensorflowLiteParser)
const TensorShape & GetShape() const
Definition: Tensor.hpp:187
bool AreAllDimensionsSpecified() const
Checks if there is at least one dimension not specified.
Definition: Tensor.cpp:241
Dimensionality GetDimensionality() const
Function that returns the tensor type.
Definition: Tensor.hpp:92
BOOST_FIXTURE_TEST_CASE(ConstructShapeUsingListInitialization, TensorInfoFixture)
Definition: TensorTest.cpp:55
Optional< unsigned int > GetQuantizationDim() const
Definition: Tensor.cpp:485
const TensorShape & GetShape() const
Definition: Tensor.hpp:284
MemoryType GetMemoryArea() const
Definition: Tensor.hpp:292
Copyright (c) 2021 ARM Limited and Contributors.
bool GetDimensionSpecificity(unsigned int i) const
Gets information about if the dimension size has been specified or not.
Definition: Tensor.cpp:211
void SetShape(const TensorShape &newShape)
Definition: Tensor.hpp:189
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
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
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
Definition: Tensor.hpp:314
void SetNumDimensions(unsigned int numDimensions, bool initDimensionsSpecificity=false)
Sets the tensor rank and therefore the Dimensionality is set to Specified if it was not...
Definition: Tensor.cpp:219
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:464
BOOST_AUTO_TEST_CASE(CheckConvolution2dLayer)
const TensorInfo & GetInfo() const
Definition: Tensor.hpp:282
void SetDataType(DataType type)
Definition: Tensor.hpp:195
std::ostream & boost_test_print_type(std::ostream &ostr, const TensorInfo &right)
Definition: TensorTest.cpp:14
void SetQuantizationDim(const Optional< unsigned int > &quantizationDim)
Definition: Tensor.cpp:490
BOOST_AUTO_TEST_SUITE_END()
unsigned int GetNumDimensions() const
Function that returns the tensor rank.
Definition: Tensor.cpp:174
void SetDimensionSize(unsigned int i, unsigned int dimensionSize)
Sets the size of the indicated dimension and Specificity for that dimension is set to true...
Definition: Tensor.cpp:232
void SetQuantizationOffset(int32_t offset)
Definition: Tensor.cpp:480
void SetQuantizationScales(const std::vector< float > &scales)
Definition: Tensor.cpp:447
unsigned int GetNumDimensions() const
Definition: Tensor.hpp:191
bool IsAtLeastOneDimensionSpecified() const
Checks if there is at least one dimension specified.
Definition: Tensor.cpp:257