34 std::unique_ptr<Decoder<float>> params_decoderPtr = MakeDecoder<float>(inputInfo0, inputs[0]->Map());
36 const int32_t* indicesDataPtr =
reinterpret_cast<int32_t*
>(inputs[1]->Map());
37 std::vector<int32_t> indices(indicesDataPtr, indicesDataPtr + inputInfo1.
GetNumElements());
39 std::unique_ptr<Encoder<float>> output_encoderPtr = MakeEncoder<float>(outputInfo, outputs[0]->Map());
47 std::vector<unsigned int> flattenedCoeff(keyIndices[
"ND"], 1);
48 for (
unsigned int i = 1; i < keyIndices[
"ND"]; ++i)
50 flattenedCoeff[i-1] = paramsShape[i];
52 for (
unsigned int i = keyIndices[
"ND"]-1; i > 0; --i)
54 flattenedCoeff[i-1] *= flattenedCoeff[i];
60 flattenedIndices_Info.
SetShape({ keyIndices[
"W"] });
61 std::vector<int32_t> flattenedIndices(flattenedIndices_Info.
GetNumElements(), 0);
64 for (
unsigned int i = 0; i < keyIndices[
"W"]; ++i)
66 for (
unsigned int j = 0; j < keyIndices[
"ND"]; ++j)
68 flattenedIndices[i] += indices[i * keyIndices[
"ND"] + j] *
static_cast<int32_t
>(flattenedCoeff[j]);
75 params_K_C_Info.
SetShape({ keyIndices[
"K"], keyIndices[
"C"] });
79 indices_N_W_Info.
SetShape({ keyIndices[
"N"], keyIndices[
"W"] });
84 outputGather_Info.
SetShape({ keyIndices[
"N"], keyIndices[
"W"], keyIndices[
"C"] });
87 Gather(params_K_C_Info, indices_N_W_Info, outputGather_Info,
88 *params_decoderPtr, flattenedIndices.data(), *output_encoderPtr, 0);
void ExecuteAsync(WorkingMemDescriptor &workingMemDescriptor) override
CPU Execution: Reference C++ kernels.
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) ...
Copyright (c) 2021 ARM Limited and Contributors.
#define ARMNN_SCOPED_PROFILING_EVENT(backendId, name)
void SetShape(const TensorShape &newShape)
std::vector< ITensorHandle * > m_Inputs
void Execute() const override
GatherNdQueueDescriptor m_Data
std::vector< ITensorHandle * > m_Outputs
std::vector< ITensorHandle * > m_Outputs
std::vector< ITensorHandle * > m_Inputs
const TensorInfo & GetTensorInfo(const ITensorHandle *tensorHandle)
float32 helpers
unsigned int GetNumElements() const