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

Function CalculateReducedOutputTensoInfo

src/armnnUtils/ParserHelper.cpp:52–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

50}
51
52void CalculateReducedOutputTensoInfo(const armnn::TensorInfo& inputTensorInfo,
53 const std::set<unsigned int>& axisSet,
54 bool keepDims,
55 armnn::TensorInfo& outputTensorInfo)
56{
57 std::vector<unsigned int> outputShapeVector;
58 bool dimensionFound = false;
59 unsigned int size = 1;
60
61 for (unsigned int i = 0; i < inputTensorInfo.GetNumDimensions(); ++i)
62 {
63 dimensionFound = false;
64 for (unsigned int axis: axisSet)
65 {
66 if (axis == i)
67 {
68 dimensionFound = true;
69 break;
70 }
71 }
72
73 if (!dimensionFound)
74 {
75 size *= inputTensorInfo.GetShape()[i];
76
77 if (keepDims)
78 {
79 outputShapeVector.push_back(inputTensorInfo.GetShape()[i]);
80 }
81 }
82 else
83 {
84 if (keepDims)
85 {
86 outputShapeVector.push_back(1);
87 }
88 }
89 }
90
91 if (keepDims)
92 {
93 armnn::TensorShape outputTensorShape(inputTensorInfo.GetNumDimensions(), &outputShapeVector[0]);
94 outputTensorInfo = armnn::TensorInfo(outputTensorShape, inputTensorInfo.GetDataType());
95 }
96 else
97 {
98 outputTensorInfo = armnn::TensorInfo({size}, inputTensorInfo.GetDataType());
99 }
100}
101
102
103void CalculateStridedSliceOutputTensorInfo(const armnn::TensorInfo& inputTensorInfo,

Callers 1

Calls 5

push_backMethod · 0.80
TensorInfoClass · 0.50
GetNumDimensionsMethod · 0.45
GetShapeMethod · 0.45
GetDataTypeMethod · 0.45

Tested by

no test coverage detected