10 #include <boost/numeric/conversion/cast.hpp> 23 if (permutationVector.
GetSize() > 0)
49 weightShape[2] * weightShape[3] });
51 weightShape[0] * weightShape[1],
58 weightInfo.
SetShape({ 1, weightShape[0] * weightShape[1], weightShape[2], weightShape[3] });
63 template <
typename DataType>
68 unsigned int multiplier;
71 unsigned int inputChannels;
75 height = weightShape[0];
76 width = weightShape[1];
77 inputChannels = weightShape[2];
78 multiplier = weightShape[3];
82 height = weightShape[2];
83 width = weightShape[3];
84 inputChannels = weightShape[1];
85 multiplier = weightShape[0];
89 std::vector<DataType> weightAclOrder(height*width*inputChannels*multiplier);
90 unsigned int destinationWeightsChannel;
91 unsigned int totalChannels = inputChannels * multiplier;
92 unsigned int channelSize = height * width;
93 unsigned int inputChannel = 0;
95 for (
unsigned int originWeightsChannel = 0; originWeightsChannel < totalChannels; originWeightsChannel++)
97 inputChannel = originWeightsChannel % inputChannels;
98 destinationWeightsChannel = (originWeightsChannel - inputChannel) / inputChannels + multiplier * inputChannel;
100 for (
unsigned int i = 0; i < channelSize; i++)
102 weightAclOrder[i + destinationWeightsChannel * channelSize] =
103 weight[i + originWeightsChannel * channelSize];
131 return weightPermutedInfo;
155 permutationVector = { 3, 2, 0, 1 };
165 weightPermuted = ReorderWeightChannelsForAcl<float>(weightPermuted, dataLayout, permuteBuffer);
169 ReorderWeightChannelsForAcl<half_float::half>(weightPermuted, dataLayout, permuteBuffer);
173 weightPermuted = ReorderWeightChannelsForAcl<uint8_t>(weightPermuted, dataLayout, permuteBuffer);
179 weightPermuted = ReorderWeightChannelsForAcl<int8_t>(weightPermuted, dataLayout, permuteBuffer);
191 return weightPermuted;
196 int32_t reversedMask = 0;
197 for (
unsigned int i = 0; i < boost::numeric_cast<unsigned int>(numDim); ++i)
200 int32_t bit = (mask & 1 << i) != 0;
202 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
#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 TensorInfo & GetTensorInfo() const
constexpr unsigned int GetDataTypeSize(DataType dataType)