ArmNN
 20.05
TensorUtilsTest.cpp File Reference
#include <armnn/Types.hpp>
#include <armnnUtils/TensorUtils.hpp>
#include <boost/test/unit_test.hpp>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (ExpandDimsAxis0Test)
 
 BOOST_AUTO_TEST_CASE (ExpandDimsAxis1Test)
 
 BOOST_AUTO_TEST_CASE (ExpandDimsAxis2Test)
 
 BOOST_AUTO_TEST_CASE (ExpandDimsAxis3Test)
 
 BOOST_AUTO_TEST_CASE (ExpandDimsNegativeAxis1Test)
 
 BOOST_AUTO_TEST_CASE (ExpandDimsNegativeAxis2Test)
 
 BOOST_AUTO_TEST_CASE (ExpandDimsNegativeAxis3Test)
 
 BOOST_AUTO_TEST_CASE (ExpandDimsNegativeAxis4Test)
 
 BOOST_AUTO_TEST_CASE (ExpandDimsInvalidAxisTest)
 
 BOOST_AUTO_TEST_CASE (ExpandDimsInvalidNegativeAxisTest)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/10]

BOOST_AUTO_TEST_CASE ( ExpandDimsAxis0Test  )

Definition at line 17 of file TensorUtilsTest.cpp.

References armnnUtils::ExpandDims().

18 {
19  armnn::TensorShape inputShape({ 2, 3, 4 });
20 
21  // Expand dimension 0
22  armnn::TensorShape outputShape = ExpandDims(inputShape, 0);
23  BOOST_TEST(outputShape.GetNumDimensions() == 4);
24  BOOST_TEST(outputShape[0] == 1);
25  BOOST_TEST(outputShape[1] == 2);
26  BOOST_TEST(outputShape[2] == 3);
27  BOOST_TEST(outputShape[3] == 4);
28 }
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:85

◆ BOOST_AUTO_TEST_CASE() [2/10]

BOOST_AUTO_TEST_CASE ( ExpandDimsAxis1Test  )

Definition at line 30 of file TensorUtilsTest.cpp.

References armnnUtils::ExpandDims().

31 {
32  armnn::TensorShape inputShape({ 2, 3, 4 });
33 
34  // Expand dimension 1
35  armnn::TensorShape outputShape = ExpandDims(inputShape, 1);
36  BOOST_TEST(outputShape.GetNumDimensions() == 4);
37  BOOST_TEST(outputShape[0] == 2);
38  BOOST_TEST(outputShape[1] == 1);
39  BOOST_TEST(outputShape[2] == 3);
40  BOOST_TEST(outputShape[3] == 4);
41 }
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:85

◆ BOOST_AUTO_TEST_CASE() [3/10]

BOOST_AUTO_TEST_CASE ( ExpandDimsAxis2Test  )

Definition at line 43 of file TensorUtilsTest.cpp.

References armnnUtils::ExpandDims().

44 {
45  armnn::TensorShape inputShape({ 2, 3, 4 });
46 
47  // Expand dimension 2
48  armnn::TensorShape outputShape = ExpandDims(inputShape, 2);
49  BOOST_TEST(outputShape.GetNumDimensions() == 4);
50  BOOST_TEST(outputShape[0] == 2);
51  BOOST_TEST(outputShape[1] == 3);
52  BOOST_TEST(outputShape[2] == 1);
53  BOOST_TEST(outputShape[3] == 4);
54 }
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:85

◆ BOOST_AUTO_TEST_CASE() [4/10]

BOOST_AUTO_TEST_CASE ( ExpandDimsAxis3Test  )

Definition at line 56 of file TensorUtilsTest.cpp.

References armnnUtils::ExpandDims().

57 {
58  armnn::TensorShape inputShape({ 2, 3, 4 });
59 
60  // Expand dimension 3
61  armnn::TensorShape outputShape = ExpandDims(inputShape, 3);
62  BOOST_TEST(outputShape.GetNumDimensions() == 4);
63  BOOST_TEST(outputShape[0] == 2);
64  BOOST_TEST(outputShape[1] == 3);
65  BOOST_TEST(outputShape[2] == 4);
66  BOOST_TEST(outputShape[3] == 1);
67 }
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:85

◆ BOOST_AUTO_TEST_CASE() [5/10]

BOOST_AUTO_TEST_CASE ( ExpandDimsNegativeAxis1Test  )

Definition at line 69 of file TensorUtilsTest.cpp.

References armnnUtils::ExpandDims().

70 {
71  armnn::TensorShape inputShape({ 2, 3, 4 });
72 
73  // Expand dimension -1
74  armnn::TensorShape outputShape = ExpandDims(inputShape, -1);
75  BOOST_TEST(outputShape.GetNumDimensions() == 4);
76  BOOST_TEST(outputShape[0] == 2);
77  BOOST_TEST(outputShape[1] == 3);
78  BOOST_TEST(outputShape[2] == 4);
79  BOOST_TEST(outputShape[3] == 1);
80 }
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:85

◆ BOOST_AUTO_TEST_CASE() [6/10]

BOOST_AUTO_TEST_CASE ( ExpandDimsNegativeAxis2Test  )

Definition at line 82 of file TensorUtilsTest.cpp.

References armnnUtils::ExpandDims().

83 {
84  armnn::TensorShape inputShape({ 2, 3, 4 });
85 
86  // Expand dimension -2
87  armnn::TensorShape outputShape = ExpandDims(inputShape, -2);
88  BOOST_TEST(outputShape.GetNumDimensions() == 4);
89  BOOST_TEST(outputShape[0] == 2);
90  BOOST_TEST(outputShape[1] == 3);
91  BOOST_TEST(outputShape[2] == 1);
92  BOOST_TEST(outputShape[3] == 4);
93 }
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:85

◆ BOOST_AUTO_TEST_CASE() [7/10]

BOOST_AUTO_TEST_CASE ( ExpandDimsNegativeAxis3Test  )

Definition at line 95 of file TensorUtilsTest.cpp.

References armnnUtils::ExpandDims().

96 {
97  armnn::TensorShape inputShape({ 2, 3, 4 });
98 
99  // Expand dimension -3
100  armnn::TensorShape outputShape = ExpandDims(inputShape, -3);
101  BOOST_TEST(outputShape.GetNumDimensions() == 4);
102  BOOST_TEST(outputShape[0] == 2);
103  BOOST_TEST(outputShape[1] == 1);
104  BOOST_TEST(outputShape[2] == 3);
105  BOOST_TEST(outputShape[3] == 4);
106 }
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:85

◆ BOOST_AUTO_TEST_CASE() [8/10]

BOOST_AUTO_TEST_CASE ( ExpandDimsNegativeAxis4Test  )

Definition at line 108 of file TensorUtilsTest.cpp.

References armnnUtils::ExpandDims().

109 {
110  armnn::TensorShape inputShape({ 2, 3, 4 });
111 
112  // Expand dimension -4
113  armnn::TensorShape outputShape = ExpandDims(inputShape, -4);
114  BOOST_TEST(outputShape.GetNumDimensions() == 4);
115  BOOST_TEST(outputShape[0] == 1);
116  BOOST_TEST(outputShape[1] == 2);
117  BOOST_TEST(outputShape[2] == 3);
118  BOOST_TEST(outputShape[3] == 4);
119 }
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:85

◆ BOOST_AUTO_TEST_CASE() [9/10]

BOOST_AUTO_TEST_CASE ( ExpandDimsInvalidAxisTest  )

Definition at line 121 of file TensorUtilsTest.cpp.

References armnnUtils::ExpandDims().

122 {
123  armnn::TensorShape inputShape({ 2, 3, 4 });
124 
125  // Invalid expand dimension 4
126  BOOST_CHECK_THROW(ExpandDims(inputShape, 4), armnn::InvalidArgumentException);
127 }
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:85

◆ BOOST_AUTO_TEST_CASE() [10/10]

BOOST_AUTO_TEST_CASE ( ExpandDimsInvalidNegativeAxisTest  )

Definition at line 129 of file TensorUtilsTest.cpp.

References BOOST_AUTO_TEST_SUITE_END(), and armnnUtils::ExpandDims().

130 {
131  armnn::TensorShape inputShape({ 2, 3, 4 });
132 
133  // Invalid expand dimension -5
134  BOOST_CHECK_THROW(ExpandDims(inputShape, -5), armnn::InvalidArgumentException);
135 }
armnn::TensorShape ExpandDims(const armnn::TensorShape &tensorShape, int axis)
Definition: TensorUtils.cpp:85