| 10 | { |
| 11 | |
| 12 | void Stack(const StackQueueDescriptor& data, |
| 13 | std::vector<std::unique_ptr<Decoder<float>>>& inputs, |
| 14 | Encoder<float>& output, |
| 15 | const TensorInfo& inputInfo, |
| 16 | const TensorInfo& outputInfo) |
| 17 | { |
| 18 | unsigned int outputNumDims = outputInfo.GetNumDimensions(); |
| 19 | unsigned int inputNumDims = inputInfo.GetNumDimensions(); |
| 20 | |
| 21 | const armnn::TensorShape& outputDims = outputInfo.GetShape(); |
| 22 | const armnn::TensorShape& inputDims = inputInfo.GetShape(); |
| 23 | |
| 24 | unsigned int axis = data.m_Parameters.m_Axis; |
| 25 | |
| 26 | // Can perform a simple concatenation when axis == 0 |
| 27 | if (!axis) |
| 28 | { |
| 29 | unsigned int numInputs = data.m_Parameters.m_NumInputs; |
| 30 | unsigned int inputLength = inputInfo.GetNumElements(); |
| 31 | |
| 32 | for (unsigned int inputIdx=0; inputIdx<numInputs; ++inputIdx) |
| 33 | { |
| 34 | for (unsigned int elmt=0; elmt<inputLength; ++elmt) |
| 35 | { |
| 36 | (*inputs[inputIdx])[elmt]; |
| 37 | output[(inputIdx * inputLength) + elmt]; |
| 38 | output.Set(inputs[inputIdx]->Get()); |
| 39 | } |
| 40 | } |
| 41 | return; |
| 42 | } |
| 43 | |
| 44 | const unsigned int iNumTensors = static_cast<unsigned int>(data.m_Inputs.size()); |
| 45 | const unsigned int iBatchSize = inputDims[0]; |
| 46 | const unsigned int iChannels = (inputNumDims > 1) ? inputDims[1] : 1; |
| 47 | const unsigned int iHeight = (inputNumDims > 2) ? inputDims[2] : 1; |
| 48 | const unsigned int iWidth = (inputNumDims > 3) ? inputDims[3] : 1; |
| 49 | |
| 50 | const unsigned int oBatchSize = outputDims[1]; |
| 51 | const unsigned int oChannels = (outputNumDims > 2) ? outputDims[2] : 1; |
| 52 | const unsigned int oHeight = (outputNumDims > 3) ? outputDims[3] : 1; |
| 53 | const unsigned int oWidth = (outputNumDims > 4) ? outputDims[4] : 1; |
| 54 | |
| 55 | // Array to store the input coordinates |
| 56 | // iCoordinates[0] = i, iCoordinates[1] = bi, iCoordinates[2] = ci |
| 57 | // iCoordinates[3] = hi, iCoordinates[4] = wi, iCoordinates[5] = 0 |
| 58 | // iCoordinates[5] will be always zero and used for not incrementing |
| 59 | // the output when the input has less than 4 dimensions |
| 60 | std::array<unsigned int, 6> iCoordinates{ 0 }; |
| 61 | |
| 62 | // Array of pointers used to map the output coordinates to the input ones, in accordance with the axis |
| 63 | // This array is initialized with &iCoordinates[5] since this will be always zero |
| 64 | std::array<unsigned int *, 5> oCoordinates = { &iCoordinates[5], |
| 65 | &iCoordinates[5], |
| 66 | &iCoordinates[5], |
| 67 | &iCoordinates[5], |
| 68 | &iCoordinates[5] }; |
| 69 |
no test coverage detected