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());
100 arm_compute::PadStrideInfo padStrideInfo = BuildArmComputePadStrideInfo(
m_Data.
m_Parameters);
107 auto convolutionLayer = std::make_unique<arm_compute::NEConvolutionLayer>(memoryManager);
108 convolutionLayer->configure(&input,
109 m_KernelTensor.get(),
113 arm_compute::WeightsInfo(),
118 m_ConvolutionMethod =
119 convolutionLayer->get_convolution_method(input.info(),
120 m_KernelTensor->info(),
123 arm_compute::WeightsInfo(),
141 m_ConvolutionLayer.reset(convolutionLayer.release());
142 m_KernelTensorInfo =
info.m_InputTensorInfos[1];
146 m_BiasTensorInfo =
info.m_InputTensorInfos[2];
162 m_ConvolutionLayer->prepare();
163 FreeTensorIfUnused(m_KernelTensor);
164 FreeTensorIfUnused(m_BiasTensor);
167 m_ConvolutionLayer->run();
172 return m_ConvolutionMethod;