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

Function CalculateStridedSliceOutputTensorInfo

src/armnnUtils/ParserHelper.cpp:103–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

101
102
103void CalculateStridedSliceOutputTensorInfo(const armnn::TensorInfo& inputTensorInfo,
104 const armnn::StridedSliceDescriptor& desc,
105 armnn::TensorInfo& outputTensorInfo)
106{
107 const armnn::TensorShape& inputShape = inputTensorInfo.GetShape();
108
109 std::vector<unsigned int> outputShapeVector;
110 for (unsigned int i = 0; i < inputTensorInfo.GetNumDimensions(); i++)
111 {
112 if (desc.m_ShrinkAxisMask & (1 << i))
113 {
114 continue;
115 }
116
117 int stride = desc.m_Stride[i];
118 int start = desc.GetStartForAxis(inputShape, i);
119 int stop = desc.GetStopForAxis(inputShape, i, start);
120
121 int newSize = stride > 0 ? ((stop - start) + stride - 1) / stride :
122 ((start - stop) - stride - 1) / -stride;
123
124 newSize = std::max(0, newSize);
125
126 outputShapeVector.push_back(static_cast<unsigned int>(newSize));
127 }
128
129 armnn::TensorShape outputTensorShape(inputTensorInfo.GetNumDimensions(), &outputShapeVector[0]);
130 outputTensorInfo = armnn::TensorInfo(armnn::TensorShape(outputTensorShape), inputTensorInfo.GetDataType());
131}
132} // namespace armnnUtils

Callers

nothing calls this directly

Calls 8

GetStartForAxisMethod · 0.80
GetStopForAxisMethod · 0.80
push_backMethod · 0.80
TensorShapeClass · 0.70
TensorInfoClass · 0.50
GetShapeMethod · 0.45
GetNumDimensionsMethod · 0.45
GetDataTypeMethod · 0.45

Tested by

no test coverage detected