From ee1497c400db10134ab540005e105f64bd0f486a Mon Sep 17 00:00:00 2001 From: Teresa Charlin Date: Thu, 30 Mar 2023 13:56:34 +0100 Subject: IVGCVSW-7454 Enable NonConstWeights in GpuAcc * Set flag for constant weights and bias in ACL tensorInfo in ACl workloads * Set flag for constant weights and bias in Unit Tests * Add to dot file for FullyConnected layer the constantWeights flag Signed-off-by: Teresa Charlin Change-Id: I87e1fef516ce4a8a59245dfdf7d92c153418e1d6 --- .../cl/workloads/ClConvolution2dWorkload.cpp | 8 +++- .../workloads/ClDepthwiseConvolutionWorkload.cpp | 41 ++++++++++-------- .../cl/workloads/ClFullyConnectedWorkload.cpp | 50 ++++++++++++---------- 3 files changed, 58 insertions(+), 41 deletions(-) (limited to 'src/backends/cl/workloads') diff --git a/src/backends/cl/workloads/ClConvolution2dWorkload.cpp b/src/backends/cl/workloads/ClConvolution2dWorkload.cpp index 1920f2d20b..d6a72e6488 100644 --- a/src/backends/cl/workloads/ClConvolution2dWorkload.cpp +++ b/src/backends/cl/workloads/ClConvolution2dWorkload.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017, 2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -88,9 +88,15 @@ ClConvolution2dWorkload::ClConvolution2dWorkload(const Convolution2dQueueDescrip arm_compute::ICLTensor& input = static_cast(m_Data.m_Inputs[0])->GetTensor(); arm_compute::ICLTensor& output = static_cast(m_Data.m_Outputs[0])->GetTensor(); arm_compute::ICLTensor& weights = static_cast(m_Data.m_Inputs[1])->GetTensor(); + weights.info()->set_are_values_constant(info.m_InputTensorInfos[1].IsConstant()); + if (m_Data.m_Parameters.m_BiasEnabled) { arm_compute::ICLTensor& bias = static_cast(m_Data.m_Inputs[2])->GetTensor(); + bias.info()->set_are_values_constant(info.m_InputTensorInfos[2].IsConstant()); + // We do not support dynamic bias + ARMNN_ASSERT(info.m_InputTensorInfos[2].IsConstant() == true); + m_BiasProxy = std::make_unique(&bias); } diff --git a/src/backends/cl/workloads/ClDepthwiseConvolutionWorkload.cpp b/src/backends/cl/workloads/ClDepthwiseConvolutionWorkload.cpp index 041cb8b0fc..e6c9cb5c20 100644 --- a/src/backends/cl/workloads/ClDepthwiseConvolutionWorkload.cpp +++ b/src/backends/cl/workloads/ClDepthwiseConvolutionWorkload.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017,2022-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -91,28 +91,12 @@ ClDepthwiseConvolutionWorkload::ClDepthwiseConvolutionWorkload( const arm_compute::CLCompileContext& clCompileContext) : ClBaseWorkload(descriptor, info) { - // Add details for profiling output - WorkloadInfo detailsInfo; - - detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos; - detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos; - detailsInfo.m_WeightsTensorInfo = armnn::Optional(info.m_InputTensorInfos[1]); - if (descriptor.m_Parameters.m_BiasEnabled) - { - detailsInfo.m_BiasTensorInfo = armnn::Optional(info.m_InputTensorInfos[2]); - } - - // Report Profiling Details - ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClDepthwiseConvolutionWorkload_Construct", - descriptor.m_Parameters, - detailsInfo, - GetGuid()); - m_Data.ValidateInputsOutputs("ClDepthwiseConv2dWorkload", descriptor.m_Parameters.GetNumInputs(), 1); arm_compute::ICLTensor& input = PolymorphicDowncast(m_Data.m_Inputs[0])->GetTensor(); arm_compute::ICLTensor& output = PolymorphicDowncast(m_Data.m_Outputs[0])->GetTensor(); arm_compute::ICLTensor& weights = PolymorphicDowncast(m_Data.m_Inputs[1])->GetTensor(); + weights.info()->set_are_values_constant(info.m_InputTensorInfos[1].IsConstant()); arm_compute::ITensorInfo* weightsInfo = weights.info(); arm_compute::ITensorInfo* inputInfo = input.info(); auto weightsShape = weightsInfo->tensor_shape(); @@ -127,6 +111,9 @@ ClDepthwiseConvolutionWorkload::ClDepthwiseConvolutionWorkload( if (m_Data.m_Parameters.m_BiasEnabled) { bias = &PolymorphicDowncast(m_Data.m_Inputs[2])->GetTensor(); + bias->info()->set_are_values_constant(info.m_InputTensorInfos[2].IsConstant()); + // We do not support dynamic bias + ARMNN_ASSERT(info.m_InputTensorInfos[2].IsConstant() == true); } const arm_compute::Size2D aclDilationInfo = BuildArmComputeSize2D( @@ -158,6 +145,24 @@ ClDepthwiseConvolutionWorkload::ClDepthwiseConvolutionWorkload( aclDilationInfo); } ARMNN_ASSERT(m_DepthwiseConvolutionLayer); + + // Add details for profiling output + WorkloadInfo detailsInfo; + + detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos; + detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos; + detailsInfo.m_WeightsTensorInfo = armnn::Optional(info.m_InputTensorInfos[1]); + + if (descriptor.m_Parameters.m_BiasEnabled) + { + detailsInfo.m_BiasTensorInfo = armnn::Optional(info.m_InputTensorInfos[2]); + } + + // Report Profiling Details + ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClDepthwiseConvolutionWorkload_Construct", + descriptor.m_Parameters, + detailsInfo, + GetGuid()); } void ClDepthwiseConvolutionWorkload::Execute() const diff --git a/src/backends/cl/workloads/ClFullyConnectedWorkload.cpp b/src/backends/cl/workloads/ClFullyConnectedWorkload.cpp index 22df04fc76..1f26b09964 100644 --- a/src/backends/cl/workloads/ClFullyConnectedWorkload.cpp +++ b/src/backends/cl/workloads/ClFullyConnectedWorkload.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017,2022-2023 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -46,6 +46,7 @@ arm_compute::Status ClFullyConnectedWorkloadValidate(const TensorInfo& input, const arm_compute::FullyConnectedLayerInfo fullyConnectedLayerInfo = ConvertFullyConnectedDescriptorToAclFullyConnectedLayerInfo(descriptor, activationDescriptor); + return arm_compute::CLFullyConnectedLayer::validate(&aclInput, &aclWeights, optionalAclBiases, @@ -60,34 +61,22 @@ ClFullyConnectedWorkload::ClFullyConnectedWorkload( const arm_compute::CLCompileContext& clCompileContext) : ClBaseWorkload(descriptor, info), m_FullyConnectedLayer(memoryManager) { - // Add details for profiling output - WorkloadInfo detailsInfo; + m_Data.ValidateInputsOutputs("ClFullyConnectedWorkload", descriptor.m_Parameters.GetNumInputs(), 1); - detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos; - detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos; - detailsInfo.m_WeightsTensorInfo = armnn::Optional(info.m_InputTensorInfos[1]); - if (descriptor.m_Parameters.m_BiasEnabled) - { - detailsInfo.m_BiasTensorInfo = armnn::Optional(info.m_InputTensorInfos[2]); - } - - // Report Profiling Details - ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClFullyConnectedWorkload_Construct", - descriptor.m_Parameters, - detailsInfo, - this->GetGuid()); - - m_Data.ValidateInputsOutputs("ClFullyConnectedWorkload", descriptor.m_Parameters.GetNumInputs(), - 1); - - arm_compute::ICLTensor& input = static_cast(m_Data.m_Inputs[0])->GetTensor(); - arm_compute::ICLTensor& output = static_cast(m_Data.m_Outputs[0])->GetTensor(); + arm_compute::ICLTensor& input = PolymorphicDowncast(m_Data.m_Inputs[0])->GetTensor(); + arm_compute::ICLTensor& output = PolymorphicDowncast(m_Data.m_Outputs[0])->GetTensor(); arm_compute::ICLTensor& weights = PolymorphicDowncast(m_Data.m_Inputs[1])->GetTensor(); + weights.info()->set_are_values_constant(info.m_InputTensorInfos[1].IsConstant()); + arm_compute::ICLTensor* bias = nullptr; if (m_Data.m_Parameters.m_BiasEnabled) { bias = &PolymorphicDowncast(m_Data.m_Inputs[2])->GetTensor(); + bias->info()->set_are_values_constant(info.m_InputTensorInfos[2].IsConstant()); + + // We do not support dynamic bias + ARMNN_ASSERT(info.m_InputTensorInfos[2].IsConstant() == true); } const arm_compute::ActivationLayerInfo activationInfo = ConvertAdditionalInfoToAclActivationLayerInfo(descriptor); @@ -105,6 +94,23 @@ ClFullyConnectedWorkload::ClFullyConnectedWorkload( &output, fc_info); } + + // Add details for profiling output + WorkloadInfo detailsInfo; + + detailsInfo.m_InputTensorInfos = info.m_InputTensorInfos; + detailsInfo.m_OutputTensorInfos = info.m_OutputTensorInfos; + detailsInfo.m_WeightsTensorInfo = armnn::Optional(info.m_InputTensorInfos[1]); + if (descriptor.m_Parameters.m_BiasEnabled) + { + detailsInfo.m_BiasTensorInfo = armnn::Optional(info.m_InputTensorInfos[2]); + } + + // Report Profiling Details + ARMNN_REPORT_PROFILING_WORKLOAD_DESC("ClFullyConnectedWorkload_Construct", + descriptor.m_Parameters, + detailsInfo, + this->GetGuid()); } void ClFullyConnectedWorkload::Execute() const -- cgit v1.2.1