12 #include <fmt/format.h>
26 if (permutationVector.
GetSize() > 0)
52 weightShape[2] * weightShape[3] });
54 weightShape[0] * weightShape[1],
61 weightInfo.
SetShape({ 1, weightShape[0] * weightShape[1], weightShape[2], weightShape[3] });
66 template <
typename DataType>
71 unsigned int multiplier;
74 unsigned int inputChannels;
78 height = weightShape[0];
79 width = weightShape[1];
80 inputChannels = weightShape[2];
81 multiplier = weightShape[3];
85 height = weightShape[2];
86 width = weightShape[3];
87 inputChannels = weightShape[1];
88 multiplier = weightShape[0];
92 std::vector<DataType> weightAclOrder(height*width*inputChannels*multiplier);
93 unsigned int destinationWeightsChannel;
94 unsigned int totalChannels = inputChannels * multiplier;
95 unsigned int channelSize = height * width;
96 unsigned int inputChannel = 0;
98 for (
unsigned int originWeightsChannel = 0; originWeightsChannel < totalChannels; originWeightsChannel++)
100 inputChannel = originWeightsChannel % inputChannels;
101 destinationWeightsChannel = (originWeightsChannel - inputChannel) / inputChannels + multiplier * inputChannel;
103 for (
unsigned int i = 0; i < channelSize; i++)
105 weightAclOrder[i + destinationWeightsChannel * channelSize] =
106 weight[i + originWeightsChannel * channelSize];
135 return weightPermutedInfo;
145 unsigned int depthMultiplier = 1;
157 permutationVector = { 0, 2, 3, 1 };
167 return std::make_tuple(weightsPermuted, depthMultiplier);
174 unsigned int aclDepthMultiplier = 1;
180 weightsPermuted = weightInfo;
197 return std::make_tuple(weightsPermuted, aclDepthMultiplier);
211 "quantization is applied.");
215 auto weightsShape = weightsInfo.
GetShape();
217 unsigned int depthMultiplier = weightsShape[3] / inputInfo.
GetShape()[channelIndex];
218 weightsInfo.
SetShape({ weightsShape[1],
227 return std::make_tuple(weightsPermuted, depthMultiplier);
251 permutationVector = { 3, 2, 0, 1 };
261 weightPermuted = ReorderWeightChannelsForAcl<float>(weightPermuted, dataLayout, permuteBuffer);
265 ReorderWeightChannelsForAcl<half_float::half>(weightPermuted, dataLayout, permuteBuffer);
269 weightPermuted = ReorderWeightChannelsForAcl<uint8_t>(weightPermuted, dataLayout, permuteBuffer);
272 weightPermuted = ReorderWeightChannelsForAcl<int8_t>(weightPermuted, dataLayout, permuteBuffer);
283 return weightPermuted;
288 int32_t reversedMask = 0;
289 for (
unsigned int i = 0; i < armnn::numeric_cast<unsigned int>(numDim); ++i)
292 int32_t bit = (mask & 1 << i) != 0;
294 reversedMask += (bit << std::max(numDim-(armnn::numeric_cast<int>(i)+1), 0));
302 std::vector<unsigned int> paramsShape;
305 paramsShape.push_back(inputInfo0.
GetShape()[i]);
308 std::vector<unsigned int> indicesShape;
311 indicesShape.push_back(inputInfo1.
GetShape()[i]);
314 std::map<std::string, unsigned int> keyIndices;
320 keyIndices[
"ND"] = indicesShape.back();
324 static_cast<unsigned int>(std::accumulate(std::begin(indicesShape),
325 std::end(indicesShape) - 1,
327 std::multiplies<>() ));
330 static_cast<unsigned int>(std::accumulate(std::begin(paramsShape),
331 std::begin(paramsShape) +
static_cast<int>(keyIndices[
"ND"]),
333 std::multiplies<>() ));
336 static_cast<unsigned int>(std::accumulate(std::begin(paramsShape) +
static_cast<int>(keyIndices[
"ND"]),
337 std::end(paramsShape),
339 std::multiplies<>() ));
350 permutationVector = {1U, 0U};
353 permutationVector = {0U, 2U, 1U};
356 permutationVector = {0U, 1U, 3U, 2U};
359 throw Exception(
"Invalid number of dimensions.");
361 return permutationVector;