| 84 | } // Anonymous namespace |
| 85 | |
| 86 | void StridedSlice(const TensorInfo& inputInfo, |
| 87 | const StridedSliceDescriptor& params, |
| 88 | const void* inputData, |
| 89 | void* outputData, |
| 90 | unsigned int dataTypeSize) |
| 91 | { |
| 92 | if (inputData == nullptr) |
| 93 | { |
| 94 | throw armnn::InvalidArgumentException("Slice: Null inputData pointer"); |
| 95 | } |
| 96 | if (outputData == nullptr) |
| 97 | { |
| 98 | throw armnn::InvalidArgumentException("Slice: Null outputData pointer"); |
| 99 | } |
| 100 | |
| 101 | const unsigned char* input = reinterpret_cast<const unsigned char*>(inputData); |
| 102 | unsigned char* output = reinterpret_cast<unsigned char*>(outputData); |
| 103 | |
| 104 | const TensorShape inputShape = ExtendShape(inputInfo.GetShape(), 4); |
| 105 | |
| 106 | StridedSliceDescriptor paddedParams = params; |
| 107 | |
| 108 | // Pad parameters to 4 dimensions |
| 109 | PadParams(paddedParams, 4); |
| 110 | |
| 111 | // Arrays containing the start and stop index for each axis (adjusted by set params/flags) |
| 112 | int startArray [4] = {0}; |
| 113 | int stopArray [4] = {0}; |
| 114 | |
| 115 | // Getting paddedParams stop and start values for each axis |
| 116 | for(unsigned int i = 0; i < 4; ++i) |
| 117 | { |
| 118 | startArray[i] = paddedParams.GetStartForAxis(inputShape, i); |
| 119 | stopArray[i] = paddedParams.GetStopForAxis(inputShape, i, startArray[i]); |
| 120 | } |
| 121 | |
| 122 | // Adjusting the EllipsisMask based on the NewAxisMask |
| 123 | // (if NewAxisMask extends an axis, the ellipsis flag is extended as well) |
| 124 | if(paddedParams.m_NewAxisMask > 0 && paddedParams.m_EllipsisMask > 0) |
| 125 | { |
| 126 | // Iterate until the current EllipsisMask 1-bit found |
| 127 | for(unsigned int i = 0; i < 4; ++i) |
| 128 | { |
| 129 | // If EllipsisMask bit found, adjust based on NewAxisMask and exit loop |
| 130 | if(paddedParams.m_EllipsisMask & (1 << i) && !(paddedParams.m_NewAxisMask & (1 << i))) |
| 131 | { |
| 132 | // If the previous bit is the NewAxisMask, set the EllipsisMask there |
| 133 | // (this condition was determined based on the unit tests expected data) |
| 134 | if(paddedParams.m_NewAxisMask & (1 << (i-1))) |
| 135 | { |
| 136 | paddedParams.m_EllipsisMask |= (1 << (i-1)); |
| 137 | } |
| 138 | // Otherwise, extend the EllipsisMask by one bit |
| 139 | else |
| 140 | { |
| 141 | paddedParams.m_EllipsisMask |= (1 << (i+1)); |
| 142 | } |
| 143 | break; |
no test coverage detected