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);
50 arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(aclOutputMulInfo.num_dimensions(),
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)
97 return arm_compute::Status(arm_compute::ErrorCode::OK,
98 "All GatherND layers validate status OK.");
102 return arm_compute::Status(arm_compute::ErrorCode::RUNTIME_ERROR,
103 "GatherND layer validate status failed.");
111 m_Data.ValidateInputsOutputs(
"NeonGatherNdWorkload", 2, 1);
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);
177 arm_compute::Coordinates coords = BuildArmComputeReductionCoordinates(m_OutputMul.info()->num_dimensions(),
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);
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)