32 const int32_t* indicesDataPtr =
reinterpret_cast<int32_t*
>(inputs[1]->Map());
33 std::vector<int32_t> indices(indicesDataPtr, indicesDataPtr + inputInfo1.
GetNumElements());
43 std::unique_ptr<Encoder<float>> output_encoderPtr =
MakeEncoder<float>(outputInfo, outputs[0]->
Map());
50 TensorShape paramsShape = inputInfo0.
GetShape();
51 std::vector<unsigned int> flattenedCoeff(keyIndices[
"ND"], 1);
52 for (
unsigned int i = 1; i < keyIndices[
"ND"]; ++i)
54 flattenedCoeff[i-1] = paramsShape[i];
56 for (
unsigned int i = keyIndices[
"ND"]-1; i > 0; --i)
58 flattenedCoeff[i-1] *= flattenedCoeff[i];
63 armnn::TensorInfo flattenedIndices_Info = inputInfo1;
64 flattenedIndices_Info.
SetShape({ keyIndices[
"W"] });
65 std::vector<int32_t> flattenedIndices(flattenedIndices_Info.
GetNumElements(), 0);
68 for (
unsigned int i = 0; i < keyIndices[
"W"]; ++i)
70 for (
unsigned int j = 0; j < keyIndices[
"ND"]; ++j)
72 flattenedIndices[i] += indices[i * keyIndices[
"ND"] + j] *
static_cast<int32_t
>(flattenedCoeff[j]);
78 armnn::TensorInfo params_K_C_Info = inputInfo0;
79 params_K_C_Info.
SetShape({ keyIndices[
"K"], keyIndices[
"C"] });
82 armnn::TensorInfo indices_N_W_Info = inputInfo1;
83 indices_N_W_Info.
SetShape({ keyIndices[
"N"], keyIndices[
"W"] });
87 armnn::TensorInfo outputGather_Info = outputInfo;
88 outputGather_Info.
SetShape({ keyIndices[
"N"], keyIndices[
"W"], keyIndices[
"C"] });
91 Gather(params_K_C_Info, indices_N_W_Info, outputGather_Info,
92 *params_decoderPtr, flattenedIndices.data(), *output_encoderPtr, 0);
#define ARMNN_SCOPED_PROFILING_EVENT_REF_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
GatherNdQueueDescriptor m_Data
void Execute() const override
const TensorShape & GetShape() const
unsigned int GetNumElements() const
void SetShape(const TensorShape &newShape)
Copyright (c) 2021 ARM Limited and Contributors.
std::unique_ptr< Decoder< T > > MakeDecoder(const TensorInfo &info, const void *data=nullptr)
std::unique_ptr< Encoder< T > > MakeEncoder(const TensorInfo &info, void *data=nullptr)
std::map< std::string, unsigned int > CalculateGatherNdKeyIndices(TensorInfo inputInfo0, TensorInfo inputInfo1)
Calculates the key index values needed for GatherNd: N, ND, K, W, C (N is always 1)
armnn::TensorInfo GetTensorInfo(unsigned int numberOfBatches, unsigned int numberOfChannels, unsigned int height, unsigned int width, const armnn::DataLayout dataLayout, const armnn::DataType dataType)