24 indices_W_ND_Info.
SetShape({ keyIndices[
"W"], keyIndices[
"ND"] });
25 const arm_compute::TensorInfo aclIndicesInfo = BuildArmComputeTensorInfo(indices_W_ND_Info);
29 flattenedCoeff_Info.
SetShape({ keyIndices[
"ND"] });
30 const arm_compute::TensorInfo aclFlattenedCoeffInfo = BuildArmComputeTensorInfo(flattenedCoeff_Info);
33 const arm_compute::TensorInfo aclOutputMulInfo = BuildArmComputeTensorInfo(indices_W_ND_Info);
35 auto statusMul = arm_compute::NEPixelWiseMultiplication::validate(&aclIndicesInfo,
36 &aclFlattenedCoeffInfo,
39 arm_compute::ConvertPolicy::WRAP,
40 arm_compute::RoundingPolicy::TO_ZERO,
41 arm_compute::ActivationLayerInfo());
46 flattenedIndices_Info.
SetShape({ keyIndices[
"W"] });
47 const arm_compute::TensorInfo aclFlattenedIndicesInfo = BuildArmComputeTensorInfo(flattenedIndices_Info);
49 const std::vector<unsigned int> armnnReduceAxes(1, 1);
54 auto statusReduceSum = arm_compute::NEReductionOperation::validate(&aclOutputMulInfo,
55 &aclFlattenedIndicesInfo,
56 static_cast<unsigned int>(coords[0]),
57 arm_compute::ReductionOperation::SUM,
63 params_K_C_Info.
SetShape({ keyIndices[
"K"], keyIndices[
"C"] });
64 const arm_compute::TensorInfo aclParamsInfo = BuildArmComputeTensorInfo(params_K_C_Info);
68 outputGather_Info.
SetShape({ keyIndices[
"W"], keyIndices[
"C"] });
69 const arm_compute::TensorInfo aclOutputGatherInfo = BuildArmComputeTensorInfo(outputGather_Info);
73 arm_compute::NEGather::validate(&aclParamsInfo, &aclFlattenedIndicesInfo, &aclOutputGatherInfo, aclAxis);
76 const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(outputInfo);
77 const arm_compute::TensorInfo aclParamsOriginalShapeInfo = BuildArmComputeTensorInfo(paramsInfo);
78 const arm_compute::TensorInfo aclIndicesOriginalShapeInfo = BuildArmComputeTensorInfo(indicesInfo);
79 const arm_compute::TensorInfo aclParamsReshapeInfo = BuildArmComputeTensorInfo(paramsInfo);
80 const arm_compute::TensorInfo aclIndicesReshapeInfo = BuildArmComputeTensorInfo(indicesInfo);
82 auto statusOutputReshape = arm_compute::NEReshapeLayer::validate(&aclOutputGatherInfo, &aclOutputInfo);
83 auto statusParamsReshape = arm_compute::NEReshapeLayer::validate(&aclParamsOriginalShapeInfo,
84 &aclParamsReshapeInfo);
85 auto statusIndicesReshape = arm_compute::NEReshapeLayer::validate(&aclIndicesOriginalShapeInfo,
86 &aclIndicesReshapeInfo);
89 auto okCode = arm_compute::ErrorCode::OK;
90 if (statusMul.error_code() == okCode &&
91 statusReduceSum.error_code() == okCode &&
92 statusGather.error_code() == okCode &&
93 statusParamsReshape.error_code() == okCode &&
94 statusIndicesReshape.error_code() == okCode &&
95 statusOutputReshape.error_code() == okCode)
98 "All GatherND layers validate status OK.");
103 "GatherND layer validate status failed.");
117 arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(
m_Data.
m_Inputs[0])->GetTensor();
118 arm_compute::ITensor& indices = PolymorphicDowncast<IAclTensorHandle*>(
m_Data.
m_Inputs[1])->GetTensor();
119 arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(
m_Data.
m_Outputs[0])->GetTensor();
130 flattenedIndices_Info.
SetShape({ keyIndices[
"W"] });
131 BuildArmComputeTensor(m_FlattenedIndices, flattenedIndices_Info);
132 armcomputetensorutils::InitialiseArmComputeTensorEmpty(m_FlattenedIndices);
136 indicesInfoReshape.
SetShape({ keyIndices[
"W"], keyIndices[
"ND"] });
137 BuildArmComputeTensor(m_IndicesReshaped, indicesInfoReshape);
138 armcomputetensorutils::InitialiseArmComputeTensorEmpty(m_IndicesReshaped);
142 std::vector<int32_t> flattenedCoeff(keyIndices[
"ND"], 1);
143 for (
unsigned int i = 1; i < keyIndices[
"ND"]; ++i)
145 flattenedCoeff[i - 1] =
static_cast<int32_t
>(paramsShape[i]);
147 for (
unsigned int i = keyIndices[
"ND"] - 1; i > 0; --i)
149 flattenedCoeff[i - 1] *= flattenedCoeff[i];
152 flattenedCoeff_Info.
SetShape({ keyIndices[
"ND"] });
153 BuildArmComputeTensor(m_FlattenedCoeff, flattenedCoeff_Info);
154 armcomputetensorutils::InitialiseArmComputeTensorEmpty(m_FlattenedCoeff);
155 CopyArmComputeITensorData<int32_t>(flattenedCoeff.data(), m_FlattenedCoeff);
159 outputMul_Info.
SetShape({ keyIndices[
"W"], keyIndices[
"ND"] });
160 BuildArmComputeTensor(m_OutputMul, outputMul_Info);
161 armcomputetensorutils::InitialiseArmComputeTensorEmpty(m_OutputMul);
164 m_ReshapeIndicesLayer.configure(&indices, &m_IndicesReshaped);
167 m_MulLayer.configure(&m_IndicesReshaped,
171 arm_compute::ConvertPolicy::WRAP,
172 arm_compute::RoundingPolicy::TO_ZERO,
173 arm_compute::ActivationLayerInfo());
176 const std::vector<unsigned int> armnnReduceAxes(1, 1);
180 m_ReduceSumLayer.configure(&m_OutputMul,
182 static_cast<unsigned int>(coords[0]),
183 arm_compute::ReductionOperation::SUM,
189 paramsInfoReshape.
SetShape({ keyIndices[
"K"], keyIndices[
"C"] });
190 BuildArmComputeTensor(m_InputGather, paramsInfoReshape);
191 armcomputetensorutils::InitialiseArmComputeTensorEmpty(m_InputGather);
194 m_ReshapeInputLayer.configure(&input, &m_InputGather);
199 outputGather_Info.
SetShape({ keyIndices[
"W"], keyIndices[
"C"] });
200 BuildArmComputeTensor(m_OutputGather, outputGather_Info);
201 armcomputetensorutils::InitialiseArmComputeTensorEmpty(m_OutputGather);
203 m_GatherLayer.configure(&m_InputGather,
209 m_ReshapeOutputLayer.configure(&m_OutputGather, &output);
215 m_ReshapeInputLayer.run();
216 m_ReshapeIndicesLayer.run();
218 m_ReduceSumLayer.run();
220 m_ReshapeOutputLayer.run();
#define ARMNN_SCOPED_PROFILING_EVENT_NEON_NAME_GUID(label)
Creates a profiling event that uses GetGuid() and GetName() from the calling class.
virtual void Execute() const override
NeonGatherNdWorkload(const GatherNdQueueDescriptor &descriptor, const WorkloadInfo &info)
unsigned int GetNumDimensions() const
const TensorShape & GetShape() const
void SetShape(const TensorShape &newShape)
Copyright (c) 2021 ARM Limited and Contributors.
int ComputeAclAxis(const int &armnnAxis, const armnn::TensorInfo &tensor)
Function to convert ArmNN axis (left to right) to ACL axis (right to left) ranging from [-rank,...
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)
std::array< unsigned int, MaxNumOfTensorDimensions > Coordinates
arm_compute::Status NeonGatherNdWorkloadValidate(const TensorInfo ¶msInfo, const TensorInfo &indicesInfo, const TensorInfo &outputInfo)
std::vector< ITensorHandle * > m_Inputs
std::vector< ITensorHandle * > m_Outputs
void ValidateInputsOutputs(const std::string &descName, unsigned int numExpectedIn, unsigned int numExpectedOut) const
Contains information about TensorInfos of a layer.