18 void PadParams(StridedSliceDescriptor& p,
unsigned int dimCount)
22 const unsigned int beginIndicesCount =
23 armnn::numeric_cast<unsigned int>(p.m_Begin.size());
25 const unsigned int padCount = dimCount - beginIndicesCount;
27 p.m_Begin.resize(dimCount);
28 p.m_End.resize(dimCount);
29 p.m_Stride.resize(dimCount);
31 for (
unsigned int i = beginIndicesCount; i > 0; --i)
33 p.m_Stride[i + padCount - 1] = p.m_Stride[i - 1];
34 p.m_Begin[i + padCount - 1] = p.m_Begin[i - 1];
35 p.m_End[i + padCount - 1] = p.m_End[i - 1];
38 for (
unsigned int i = 0; i < padCount; ++i)
45 p.m_ShrinkAxisMask <<= padCount;
46 p.m_EllipsisMask <<= padCount;
47 p.m_NewAxisMask <<= padCount;
48 p.m_BeginMask <<= padCount;
49 p.m_EndMask <<= padCount;
50 p.m_BeginMask |= (1 << padCount) - 1;
51 p.m_EndMask |= (1 << padCount) - 1;
54 bool LoopCondition(
int index,
int stop,
int stride)
56 return stride > 0 ? index >= stop : index <= stop;
59 TensorShape ExtendShape(
const TensorShape& inputShape,
60 unsigned int newNumDimensions)
62 if (inputShape.GetNumDimensions() >= newNumDimensions)
67 std::vector<unsigned int> newSizes(newNumDimensions, 0);
69 unsigned int diff = newNumDimensions - inputShape.GetNumDimensions();
71 for (
unsigned int i = 0; i < diff; i++)
76 for (
unsigned int i = diff; i < newNumDimensions; i++)
78 newSizes[i] = inputShape[i - diff];
81 return TensorShape(newNumDimensions, newSizes.data());
88 const void* inputData,
90 unsigned int dataTypeSize)
92 if (inputData ==
nullptr)
96 if (outputData ==
nullptr)
101 const unsigned char* input =
reinterpret_cast<const unsigned char*
>(inputData);
102 unsigned char* output =
reinterpret_cast<unsigned char*
>(outputData);
109 PadParams(paddedParams, 4);
112 int startArray [4] = {0};
113 int stopArray [4] = {0};
116 for(
unsigned int i = 0; i < 4; ++i)
119 stopArray[i] = paddedParams.
GetStopForAxis(inputShape, i, startArray[i]);
127 for(
unsigned int i = 0; i < 4; ++i)
149 for(
unsigned int i = 0, dimIdx = 0; i < 4; ++i)
155 stopArray[i] = armnn::numeric_cast<int>(inputShape[i]);
170 startArray[i] = startArray[dimIdx];
171 stopArray[i] = stopArray[dimIdx];
187 stopArray[i] = armnn::numeric_cast<int>(inputShape[i]);
194 const int step = armnn::numeric_cast<int>(dataTypeSize);
196 for (
int in0 = startArray[0];
197 !LoopCondition(in0, stopArray[0], paddedParams.
m_Stride[0]);
200 for (
int in1 = startArray[1];
201 !LoopCondition(in1, stopArray[1], paddedParams.
m_Stride[1]);
204 for (
int in2 = startArray[2];
205 !LoopCondition(in2, stopArray[2], paddedParams.
m_Stride[2]);
208 for (
int in3 = startArray[3];
209 !LoopCondition(in3, stopArray[3], paddedParams.
m_Stride[3]);
212 int dim1 = armnn::numeric_cast<int>(inputShape[1]);
213 int dim2 = armnn::numeric_cast<int>(inputShape[2]);
214 int dim3 = armnn::numeric_cast<int>(inputShape[3]);
216 int inputOffset = (((in0 * dim1 + in1) * dim2 + in2) * dim3 + in3) * step;
217 ::memcpy(output, input + inputOffset, dataTypeSize);