MCPcopy Create free account
hub / github.com/ARM-software/armnn / ReduceDims

Function ReduceDims

src/armnnUtils/TensorUtils.cpp:108–132  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

106}
107
108TensorShape ReduceDims(const TensorShape& tensorShape, unsigned int dimensions)
109{
110 if (tensorShape.GetNumDimensions() <= dimensions)
111 {
112 return tensorShape;
113 }
114 std::vector<unsigned int> newShape;
115
116 unsigned int dimsToSkip = tensorShape.GetNumDimensions() - dimensions;
117 unsigned int dimsSkipped = 0;
118 bool insertRemainder = false;
119
120 for (unsigned int i = 0; i < tensorShape.GetNumDimensions(); ++i)
121 {
122 if (tensorShape[i] == 1 && dimsSkipped < dimsToSkip && !insertRemainder)
123 {
124 ++dimsSkipped;
125 continue;
126 }
127 newShape.push_back(tensorShape[i]);
128 // Once we insert the first dimension we can't skip any more
129 insertRemainder = true;
130 }
131 return TensorShape(static_cast<unsigned int>(newShape.size()), newShape.data());
132}
133
134TensorInfo ReduceDims(const TensorInfo& tensorInfo, unsigned int dimensions)
135{

Callers 1

Calls 7

push_backMethod · 0.80
SetShapeMethod · 0.80
TensorShapeClass · 0.70
GetNumDimensionsMethod · 0.45
sizeMethod · 0.45
dataMethod · 0.45
GetShapeMethod · 0.45

Tested by

no test coverage detected