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

Function ExpandDimsToRank

src/armnnUtils/TensorUtils.cpp:170–193  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

168}
169
170TensorShape ExpandDimsToRank(const TensorShape& tensorShape, unsigned int rank)
171{
172 // Can't expand if rank is smaller than current shape
173 if (tensorShape.GetNumDimensions() >= rank)
174 {
175 return tensorShape;
176 }
177
178 std::vector<unsigned int> newShape;
179
180 // First add 1s to the beginning of the tensorInfo to fill in the space
181 for (unsigned int i = 0; i < rank - tensorShape.GetNumDimensions(); ++i)
182 {
183 newShape.push_back(1);
184 }
185
186 // Then iterate through the original shape and append it to the new shape with the added 1s
187 for (unsigned int i = 0; i < tensorShape.GetNumDimensions(); ++i)
188 {
189 newShape.push_back(tensorShape[i]);
190 }
191
192 return TensorShape(static_cast<unsigned int>(newShape.size()), newShape.data());
193}
194
195std::vector<unsigned int> SqueezeDims(const TensorShape& tensorShape)
196{

Callers 2

ExpandTensorRankToEqualFunction · 0.85

Calls 5

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

Tested by

no test coverage detected