16 BOOST_ASSERT_MSG(tensor,
"Invalid input tensor");
17 BOOST_ASSERT_MSG(permuteBuffer,
"Invalid permute buffer");
21 if (permutationVector.
GetSize() > 0)
47 weightShape[2] * weightShape[3] });
49 weightShape[0] * weightShape[1],
56 weightInfo.
SetShape({ 1, weightShape[0] * weightShape[1], weightShape[2], weightShape[3] });
61 template <
typename DataType>
66 unsigned int multiplier;
69 unsigned int inputChannels;
73 height = weightShape[0];
74 width = weightShape[1];
75 inputChannels = weightShape[2];
76 multiplier = weightShape[3];
80 height = weightShape[2];
81 width = weightShape[3];
82 inputChannels = weightShape[1];
83 multiplier = weightShape[0];
87 std::vector<DataType> weightAclOrder(height*width*inputChannels*multiplier);
88 unsigned int destinationWeightsChannel;
89 unsigned int totalChannels = inputChannels * multiplier;
90 unsigned int channelSize = height * width;
91 unsigned int inputChannel = 0;
93 for (
unsigned int originWeightsChannel = 0; originWeightsChannel < totalChannels; originWeightsChannel++)
95 inputChannel = originWeightsChannel % inputChannels;
96 destinationWeightsChannel = (originWeightsChannel - inputChannel) / inputChannels + multiplier * inputChannel;
98 for (
unsigned int i = 0; i < channelSize; i++)
100 weightAclOrder[i + destinationWeightsChannel * channelSize] =
101 weight[i + originWeightsChannel * channelSize];
129 return weightPermutedInfo;
136 BOOST_ASSERT_MSG(weightTensor,
"Invalid input tensor");
137 BOOST_ASSERT_MSG(permuteBuffer,
"Invalid permute buffer");
153 permutationVector = { 3, 2, 0, 1 };
163 weightPermuted = ReorderWeightChannelsForAcl<float>(weightPermuted, dataLayout, permuteBuffer);
167 ReorderWeightChannelsForAcl<half_float::half>(weightPermuted, dataLayout, permuteBuffer);
171 weightPermuted = ReorderWeightChannelsForAcl<uint8_t>(weightPermuted, dataLayout, permuteBuffer);
177 weightPermuted = ReorderWeightChannelsForAcl<int8_t>(weightPermuted, dataLayout, permuteBuffer);
189 return weightPermuted;
194 int32_t reversedMask = 0;
195 for (
unsigned int i = 0; i < boost::numeric_cast<unsigned int>(numDim); ++i)
198 int32_t bit = (mask & 1 << i) != 0;
200 reversedMask += (bit << std::max(numDim-(boost::numeric_cast<int>(i)+1), 0));
const TensorShape & GetShape() const
armnn::ConstTensor ConvertWeightTensorFromArmnnToAcl(const ConstCpuTensorHandle *weightTensor, DataLayout dataLayout, void *permuteBuffer)
TensorInfo ConvertWeightTensorInfoFromArmnnToAcl(const TensorInfo &weightInfo, DataLayout dataLayout)
#define ARMNN_NO_DEPRECATE_WARN_BEGIN
const TensorShape & GetShape() const
unsigned int GetNumBytes() const
const T * GetConstTensor() const
Copyright (c) 2020 ARM Limited.
armnn::ConstTensor PermuteTensor(const ConstCpuTensorHandle *tensor, const PermutationVector &permutationVector, void *permuteBuffer)
ConstTensor ReorderWeightChannelsForAcl(const ConstTensor &weightHandle, DataLayout dataLayout, void *permuteBuffer)
void SetShape(const TensorShape &newShape)
#define ARMNN_NO_DEPRECATE_WARN_END
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 TensorInfo & GetTensorInfo() const
constexpr unsigned int GetDataTypeSize(DataType dataType)