14 #include <arm_compute/runtime/NEON/functions/NEConvolutionLayer.h>
22 using namespace armcomputetensorutils;
29 bool isFastMathEnabled,
32 const arm_compute::TensorInfo aclInputInfo = BuildArmComputeTensorInfo(input, descriptor.
m_DataLayout);
33 const arm_compute::TensorInfo aclOutputInfo = BuildArmComputeTensorInfo(output, descriptor.
m_DataLayout);
34 arm_compute::TensorInfo aclWeightsInfo = BuildArmComputeTensorInfo(weights, descriptor.
m_DataLayout);
35 aclWeightsInfo.set_are_values_constant(weights.
IsConstant());
37 const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D(descriptor.
m_DilationX,
40 arm_compute::TensorInfo aclBiasesInfo;
41 arm_compute::TensorInfo *optionalAclBiasesInfo =
nullptr;
48 "ArmNN NeonConvolution2dWorkload has empty bias value."};
50 aclBiasesInfo = BuildArmComputeTensorInfo(biases.
value(), descriptor.
m_DataLayout);
51 aclBiasesInfo.set_are_values_constant(biases.
value().IsConstant());
52 optionalAclBiasesInfo = &aclBiasesInfo;
55 arm_compute::PadStrideInfo layerInfo = BuildArmComputePadStrideInfo(descriptor);
58 activationDescriptor);
60 return arm_compute::NEConvolutionLayer::validate(&aclInputInfo,
62 optionalAclBiasesInfo,
65 arm_compute::WeightsInfo(),
74 std::shared_ptr<arm_compute::MemoryManagerOnDemand>& memoryManager,
75 const bool isFastMathEnabled)
78 using arm_compute::NEConvolutionLayer;
83 arm_compute::ITensor& input = PolymorphicDowncast<IAclTensorHandle*>(
m_Data.
m_Inputs[0])->GetTensor();
84 arm_compute::ITensor& output = PolymorphicDowncast<IAclTensorHandle*>(
m_Data.
m_Outputs[0])->GetTensor();
87 input.info()->set_data_layout(aclDataLayout);
88 output.info()->set_data_layout(aclDataLayout);
90 m_KernelTensor = std::make_unique<arm_compute::Tensor>();
92 m_KernelTensor->info()->set_are_values_constant(
info.m_InputTensorInfos[1].IsConstant());
95 m_BiasTensor = std::make_unique<arm_compute::Tensor>();
97 m_BiasTensor->info()->set_are_values_constant(
info.m_InputTensorInfos[2].IsConstant());
102 arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(
m_Data.
m_Parameters);
109 auto convolutionLayer = std::make_unique<arm_compute::NEConvolutionLayer>(memoryManager);
110 convolutionLayer->configure(&input,
111 m_KernelTensor.get(),
115 arm_compute::WeightsInfo(),
120 m_ConvolutionMethod =
121 convolutionLayer->get_convolution_method(input.info(),
122 m_KernelTensor->info(),
125 arm_compute::WeightsInfo(),
143 m_ConvolutionLayer.reset(convolutionLayer.release());
146 m_KernelTensorInfo =
info.m_InputTensorInfos[1];
150 m_BiasTensorInfo =
info.m_InputTensorInfos[2];
166 m_ConvolutionLayer->prepare();
167 FreeTensorIfUnused(m_KernelTensor);
168 FreeTensorIfUnused(m_BiasTensor);
171 m_ConvolutionLayer->run();
176 return m_ConvolutionMethod;