22 if (permutationVector.
GetSize() > 0)
48 weightShape[2] * weightShape[3] });
50 weightShape[0] * weightShape[1],
57 weightInfo.
SetShape({ 1, weightShape[0] * weightShape[1], weightShape[2], weightShape[3] });
62 template <
typename DataType>
67 unsigned int multiplier;
70 unsigned int inputChannels;
74 height = weightShape[0];
75 width = weightShape[1];
76 inputChannels = weightShape[2];
77 multiplier = weightShape[3];
81 height = weightShape[2];
82 width = weightShape[3];
83 inputChannels = weightShape[1];
84 multiplier = weightShape[0];
88 std::vector<DataType> weightAclOrder(height*width*inputChannels*multiplier);
89 unsigned int destinationWeightsChannel;
90 unsigned int totalChannels = inputChannels * multiplier;
91 unsigned int channelSize = height * width;
92 unsigned int inputChannel = 0;
94 for (
unsigned int originWeightsChannel = 0; originWeightsChannel < totalChannels; originWeightsChannel++)
96 inputChannel = originWeightsChannel % inputChannels;
97 destinationWeightsChannel = (originWeightsChannel - inputChannel) / inputChannels + multiplier * inputChannel;
99 for (
unsigned int i = 0; i < channelSize; i++)
101 weightAclOrder[i + destinationWeightsChannel * channelSize] =
102 weight[i + originWeightsChannel * channelSize];
130 return weightPermutedInfo;
154 permutationVector = { 3, 2, 0, 1 };
164 weightPermuted = ReorderWeightChannelsForAcl<float>(weightPermuted, dataLayout, permuteBuffer);
168 ReorderWeightChannelsForAcl<half_float::half>(weightPermuted, dataLayout, permuteBuffer);
172 weightPermuted = ReorderWeightChannelsForAcl<uint8_t>(weightPermuted, dataLayout, permuteBuffer);
178 weightPermuted = ReorderWeightChannelsForAcl<int8_t>(weightPermuted, dataLayout, permuteBuffer);
190 return weightPermuted;
195 int32_t reversedMask = 0;
196 for (
unsigned int i = 0; i < armnn::numeric_cast<unsigned int>(numDim); ++i)
199 int32_t bit = (mask & 1 << i) != 0;
201 reversedMask += (bit << std::max(numDim-(armnn::numeric_cast<int>(i)+1), 0));
armnn::ConstTensor PermuteTensor(const ConstTensorHandle *tensor, const PermutationVector &permutationVector, void *permuteBuffer)
const TensorShape & GetShape() const
TensorInfo ConvertWeightTensorInfoFromArmnnToAcl(const TensorInfo &weightInfo, DataLayout dataLayout)
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
armnn::ConstTensor ConvertWeightTensorFromArmnnToAcl(const ConstTensorHandle *weightTensor, DataLayout dataLayout, void *permuteBuffer)
const TensorShape & GetShape() const
unsigned int GetNumBytes() const
Copyright (c) 2021 ARM Limited and Contributors.
ConstTensor ReorderWeightChannelsForAcl(const ConstTensor &weightHandle, DataLayout dataLayout, void *permuteBuffer)
void SetShape(const TensorShape &newShape)
const TensorInfo & GetTensorInfo() const
#define ARMNN_NO_DEPRECATE_WARN_END
#define ARMNN_ASSERT_MSG(COND, MSG)
DataType GetDataType() const
A tensor defined by a TensorInfo (shape and data type) and an immutable backing store.
#define ARMNN_FALLTHROUGH
const TensorInfo & GetInfo() const
int32_t ConvertMaskToACLFormat(int32_t mask, int32_t numDim)
DataType GetDataType() const
void ReshapeWeightsForAcl(TensorInfo &weightInfo, DataLayout dataLayout)
armnn::TensorShape Permuted(const armnn::TensorShape &srcShape, const armnn::PermutationVector &mappings)
const T * GetConstTensor() const
constexpr unsigned int GetDataTypeSize(DataType dataType)