From ec67a0f08e0f96a5aebf3cac65331c67f6649f5e Mon Sep 17 00:00:00 2001 From: Mike Kelly Date: Fri, 25 Nov 2022 13:55:24 +0000 Subject: IVGCVSW-7209 Remove deprecated code due to be removed in 23.02 * Removed weights and bias from Convolution, DepthwiseConv & FullyConnected layers * Removed the weight and bias ConstTensorHandles from the QueueDescriptors * Updated Workloads to take tensors from WorkloadInfo rather than the QueueDescriptors * Removed unused RedirectMembersToConstantInputs optimization and tests. Signed-off-by: Teresa Charlin Signed-off-by: Mike Kelly Change-Id: I9ffcdc4a1c0dff725539dd69fc435b700bd98a56 --- .../test/layerTests/Conv2dTestImpl.cpp | 111 +++------------------ .../test/layerTests/FullyConnectedTestImpl.cpp | 11 +- 2 files changed, 15 insertions(+), 107 deletions(-) (limited to 'src/backends/backendsCommon/test/layerTests') diff --git a/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp index 1e0adc169a..8a2d8c8696 100644 --- a/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/Conv2dTestImpl.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -313,8 +313,6 @@ LayerTestResult SimpleConvolution2dTestImpl( armnn::Convolution2dQueueDescriptor data; armnn::WorkloadInfo info; - armnn::ScopedTensorHandle weightsTensor(kernelDesc); - armnn::ScopedTensorHandle biasTensor(biasDesc); // Permute the kernel if necessary std::vector kernel = originalKernel; @@ -322,12 +320,6 @@ LayerTestResult SimpleConvolution2dTestImpl( { armnnUtils::Permute(kernelDesc.GetShape(), NCHWToNHWC, originalKernel.data(), kernel.data(), sizeof(T)); } - AllocateAndCopyDataToITensorHandle(&weightsTensor, kernel.data()); - - if(biasEnabled) - { - AllocateAndCopyDataToITensorHandle(&biasTensor, bias.data()); - } AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); AddInputToWorkload(data, info, kernelDesc, weightsHandle.get()); @@ -339,8 +331,6 @@ LayerTestResult SimpleConvolution2dTestImpl( biasHandle = tensorHandleFactory.CreateTensorHandle(biasDesc); AddInputToWorkload(data, info, biasDesc, biasHandle.get()); } - data.m_Weight = &weightsTensor; - data.m_Bias = &biasTensor; // Still set this whether or not bias is enabled - can be a source of bugs. data.m_Parameters.m_StrideX = strideX; data.m_Parameters.m_StrideY = strideY; data.m_Parameters.m_PadLeft = padLeft; @@ -442,15 +432,13 @@ LayerTestResult SimpleConvolution2dNhwcTestImpl( std::unique_ptr weightsHandle = tensorHandleFactory.CreateTensorHandle(kernelDesc); std::unique_ptr biasHandle = nullptr; - armnn::ScopedTensorHandle weightsTensor(kernelDesc); - AllocateAndCopyDataToITensorHandle(&weightsTensor, kernel.data()); +// armnn::ScopedTensorHandle weightsTensor(kernelDesc); +// AllocateAndCopyDataToITensorHandle(&weightsTensor, kernel.data()); - armnn::ScopedTensorHandle biasTensor(biasDesc); +// armnn::ScopedTensorHandle biasTensor(biasDesc); armnn::Convolution2dQueueDescriptor data; - data.m_Weight = &weightsTensor; - data.m_Bias = &biasTensor; // Still set this whether or not bias is enabled - can be a source of bugs. data.m_Parameters.m_StrideX = strideX; data.m_Parameters.m_StrideY = strideY; data.m_Parameters.m_PadLeft = padLeft; @@ -590,18 +578,16 @@ LayerTestResult Convolution1dTestImpl( armnn::Convolution2dQueueDescriptor data; armnn::WorkloadInfo info; - armnn::ScopedTensorHandle weightsTensor(kernelInfo); - armnn::ScopedTensorHandle biasTensor(biasInfo); - - AllocateAndCopyDataToITensorHandle(&weightsTensor, kernelData.data()); - AllocateAndCopyDataToITensorHandle(&biasTensor, biasData.data()); +// armnn::ScopedTensorHandle weightsTensor(kernelInfo); +// armnn::ScopedTensorHandle biasTensor(biasInfo); +// +// AllocateAndCopyDataToITensorHandle(&weightsTensor, kernelData.data()); +// AllocateAndCopyDataToITensorHandle(&biasTensor, biasData.data()); AddInputToWorkload(data, info, inputInfo, inputHandle.get()); AddInputToWorkload(data, info, kernelInfo, weightsHandle.get()); AddOutputToWorkload(data, info, outputInfo, outputHandle.get()); - data.m_Weight = &weightsTensor; - data.m_Bias = &biasTensor; data.m_Parameters.m_StrideX = 1; data.m_Parameters.m_StrideY = stride; data.m_Parameters.m_PadLeft = 0; @@ -1421,25 +1407,14 @@ LayerTestResult CompareConvolution2dTestImpl( armnn::Convolution2dQueueDescriptor data; armnn::WorkloadInfo info; - armnn::ScopedTensorHandle weightsTensor(kernelDesc); - armnn::ScopedTensorHandle biasTensor(biasDesc); - AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); AddInputToWorkload(data, info, kernelDesc, weightsHandle.get()); AddInputToWorkload(data, info, biasDesc, biasHandle.get()); AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); - // AllocateAndCopyDataToITensorHandle() is required twice for the weights AND biases: - // See comment in DepthwiseConvolution2dAsymmetricTestImpl() for reasons. - // 1) ScopedTensorHandle (weightsTensor) required for QueueDescriptor (data.m_Weight). - // 2) ITensorHandle (converts to Backend TensorHandle) required in RefWorkload for GetTensorInfo() method. AllocateAndCopyDataToITensorHandle(weightsHandle.get(), kernel.data()); - AllocateAndCopyDataToITensorHandle(&weightsTensor, kernel.data()); AllocateAndCopyDataToITensorHandle(biasHandle.get(), bias.data()); - AllocateAndCopyDataToITensorHandle(&biasTensor, bias.data()); - data.m_Weight = &weightsTensor; - data.m_Bias = &biasTensor; data.m_Parameters.m_StrideX = strideX; data.m_Parameters.m_StrideY = strideY; data.m_Parameters.m_PadLeft = padX; @@ -1827,15 +1802,6 @@ LayerTestResult DepthwiseConvolution2dAsymmetricTestImpl( armnn::DepthwiseConvolution2dQueueDescriptor data; armnn::WorkloadInfo info; - armnn::ScopedTensorHandle weightsTensor(kernelDesc); - - // AllocateAndCopyDataToITensorHandle() is required twice for the weights AND biases: - // 1) ScopedTensorHandle (weightsTensor) required for QueueDescriptor (data.m_Weight). - // Needed in Neon and Cl Workload when permuting. Backend TensorHandle in (2) below will not work. - // 2) ITensorHandle (converts to Backend TensorHandle) required in RefWorkload for GetTensorInfo() method. - // Cannot PolymorphicDowncast from ScopedTensorHandle->RefTensorHandle. - // Need to PolymorphicDowncast from ITensorHandle->RefTensorHandle. - AllocateAndCopyDataToITensorHandle(&weightsTensor, kernelData.data()); AllocateAndCopyDataToITensorHandle(weightsHandle.get(), kernelData.data()); // required for ConstantTensor AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); @@ -1852,8 +1818,6 @@ LayerTestResult DepthwiseConvolution2dAsymmetricTestImpl( AddInputToWorkload(data, info, biasDesc, biasHandle.get()); } - data.m_Weight = &weightsTensor; - data.m_Bias = &biasTensor; // Still set this whether or not bias is enabled - it can be a source of bugs. data.m_Parameters.m_StrideX = strideX; data.m_Parameters.m_StrideY = strideY; data.m_Parameters.m_PadLeft = padLeft; @@ -2009,12 +1973,6 @@ LayerTestResult DepthwiseConvolution2dDepthMul1TestImpl( armnn::DepthwiseConvolution2dQueueDescriptor data; armnn::WorkloadInfo info; - armnn::ScopedTensorHandle weightsTensor(kernelDesc); - // AllocateAndCopyDataToITensorHandle() is required twice for the weights AND biases: - // See comment in DepthwiseConvolution2dAsymmetricTestImpl() for reasons. - // 1) ScopedTensorHandle (weightsTensor) required for QueueDescriptor (data.m_Weight). - // 2) ITensorHandle (converts to Backend TensorHandle) required in RefWorkload for GetTensorInfo() method. - AllocateAndCopyDataToITensorHandle(&weightsTensor, kernelData.data()); // required for QueueDescriptor AllocateAndCopyDataToITensorHandle(weightsHandle.get(), kernelData.data()); // required for ConstantTensor AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); @@ -2031,8 +1989,6 @@ LayerTestResult DepthwiseConvolution2dDepthMul1TestImpl( AddInputToWorkload(data, info, biasDesc, biasHandle.get()); } - data.m_Weight = &weightsTensor; - data.m_Bias = &biasTensor; // Still set this whether or not bias is enabled. data.m_Parameters.m_StrideX = 1; data.m_Parameters.m_StrideY = 1; data.m_Parameters.m_PadLeft = 0; @@ -2234,12 +2190,6 @@ LayerTestResult DepthwiseConvolution2dTestImpl( armnn::DepthwiseConvolution2dQueueDescriptor data; armnn::WorkloadInfo info; - armnn::ScopedTensorHandle weightsTensor(kernelDesc); - // AllocateAndCopyDataToITensorHandle() is required twice for the weights AND biases: - // See comment in DepthwiseConvolution2dAsymmetricTestImpl() for reasons. - // 1) ScopedTensorHandle (weightsTensor) required for QueueDescriptor (data.m_Weight). - // 2) ITensorHandle (converts to Backend TensorHandle) required in RefWorkload for GetTensorInfo() method. - AllocateAndCopyDataToITensorHandle(&weightsTensor, kernelData.data()); // required for QueueDescriptor AllocateAndCopyDataToITensorHandle(weightsHandle.get(), kernelData.data()); // required for ConstantTensor AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); @@ -2256,8 +2206,6 @@ LayerTestResult DepthwiseConvolution2dTestImpl( AddInputToWorkload(data, info, biasDesc, biasHandle.get()); } - data.m_Weight = &weightsTensor; - data.m_Bias = &biasTensor; // Still set this whether or not bias is enabled. data.m_Parameters.m_StrideX = 2; data.m_Parameters.m_StrideY = 1; data.m_Parameters.m_PadLeft = 0; @@ -2426,12 +2374,6 @@ LayerTestResult DepthwiseConvolution2dTestImpl( armnn::DepthwiseConvolution2dQueueDescriptor data; armnn::WorkloadInfo info; - armnn::ScopedTensorHandle weightsTensor(kernelDesc); - // AllocateAndCopyDataToITensorHandle() is required twice for the weights AND biases: - // See comment in DepthwiseConvolution2dAsymmetricTestImpl() for reasons. - // 1) ScopedTensorHandle (weightsTensor) required for QueueDescriptor (data.m_Weight). - // 2) ITensorHandle (converts to Backend TensorHandle) required in RefWorkload for GetTensorInfo() method. - AllocateAndCopyDataToITensorHandle(&weightsTensor, kernelData.data()); // required for QueueDescriptor AllocateAndCopyDataToITensorHandle(weightsHandle.get(), kernelData.data()); // required for ConstantTensor AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); @@ -2448,8 +2390,6 @@ LayerTestResult DepthwiseConvolution2dTestImpl( AddInputToWorkload(data, info, biasDesc, biasHandle.get()); } - data.m_Weight = &weightsTensor; - data.m_Bias = &biasTensor; // Still set this whether or not bias is enabled - can be a source of bugs. data.m_Parameters.m_StrideX = strideX; data.m_Parameters.m_StrideY = strideY; data.m_Parameters.m_PadLeft = padLeft; @@ -3177,25 +3117,14 @@ LayerTestResult CompareDepthwiseConvolution2dTestImpl( armnn::DepthwiseConvolution2dQueueDescriptor data; armnn::WorkloadInfo info; - armnn::ScopedTensorHandle weightsTensor(aclKernelDescriptor); - armnn::ScopedTensorHandle biasTensor(biasDesc); - AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); AddInputToWorkload(data, info, aclKernelDescriptor, weightsHandle.get()); AddInputToWorkload(data, info, biasDesc, biasHandle.get()); AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); - // AllocateAndCopyDataToITensorHandle() is required twice for the weights AND biases: - // See comment in DepthwiseConvolution2dAsymmetricTestImpl() for reasons. - // 1) ScopedTensorHandle (weightsTensor) required for QueueDescriptor (data.m_Weight). - // 2) ITensorHandle (converts to Backend TensorHandle) required in RefWorkload for GetTensorInfo() method. AllocateAndCopyDataToITensorHandle(weightsHandle.get(), aclKernelData.data()); - AllocateAndCopyDataToITensorHandle(&weightsTensor, aclKernelData.data()); AllocateAndCopyDataToITensorHandle(biasHandle.get(), bias.data()); - AllocateAndCopyDataToITensorHandle(&biasTensor, bias.data()); - data.m_Weight = &weightsTensor; - data.m_Bias = &biasTensor; data.m_Parameters.m_StrideX = strideX; data.m_Parameters.m_StrideY = strideY; data.m_Parameters.m_PadLeft = padX; @@ -3696,16 +3625,14 @@ LayerTestResult Convolution2dPerAxisQuantTest( std::unique_ptr biasHandle = nullptr; WorkloadInfo workloadInfo; - ScopedTensorHandle weightTensor(kernelInfo); - ScopedTensorHandle biasTensor(biasInfo); - - AllocateAndCopyDataToITensorHandle(&weightTensor, kernelData.data()); - AllocateAndCopyDataToITensorHandle(&biasTensor, biasData.data()); +// ScopedTensorHandle weightTensor(kernelInfo); +// ScopedTensorHandle biasTensor(biasInfo); +// +// AllocateAndCopyDataToITensorHandle(&weightTensor, kernelData.data()); +// AllocateAndCopyDataToITensorHandle(&biasTensor, biasData.data()); Convolution2dQueueDescriptor queueDescriptor; queueDescriptor.m_Parameters = descriptor; - queueDescriptor.m_Weight = &weightTensor; - queueDescriptor.m_Bias = &biasTensor; AddInputToWorkload(queueDescriptor, workloadInfo, inputInfo, inputHandle.get()); AddInputToWorkload(queueDescriptor, workloadInfo, kernelInfo, weightsHandle.get()); @@ -3995,26 +3922,16 @@ LayerTestResult DepthwiseConvolution2dPerAxisQuantTest( DepthwiseConvolution2dQueueDescriptor queueDescriptor; WorkloadInfo workloadInfo; - ScopedTensorHandle weightTensor(kernelInfo); - ScopedTensorHandle biasTensor(biasInfo); AddInputToWorkload(queueDescriptor, workloadInfo, inputInfo, inputHandle.get()); AddInputToWorkload(queueDescriptor, workloadInfo, kernelInfo, weightsHandle.get()); AddOutputToWorkload(queueDescriptor, workloadInfo, outputInfo, outputHandle.get()); AddInputToWorkload(queueDescriptor, workloadInfo, biasInfo, biasHandle.get()); - // AllocateAndCopyDataToITensorHandle() is required twice for the weights AND biases: - // See comment in DepthwiseConvolution2dAsymmetricTestImpl() for reasons. - // 1) ScopedTensorHandle (weightsTensor) required for QueueDescriptor (data.m_Weight). - // 2) ITensorHandle (converts to Backend TensorHandle) required in RefWorkload for GetTensorInfo() method. AllocateAndCopyDataToITensorHandle(weightsHandle.get(), kernelData.data()); - AllocateAndCopyDataToITensorHandle(&weightTensor, kernelData.data()); AllocateAndCopyDataToITensorHandle(biasHandle.get(), biasData.data()); - AllocateAndCopyDataToITensorHandle(&biasTensor, biasData.data()); queueDescriptor.m_Parameters = descriptor; - queueDescriptor.m_Weight = &weightTensor; - queueDescriptor.m_Bias = &biasTensor; std::unique_ptr workload = workloadFactory.CreateWorkload(armnn::LayerType::DepthwiseConvolution2d, queueDescriptor, diff --git a/src/backends/backendsCommon/test/layerTests/FullyConnectedTestImpl.cpp b/src/backends/backendsCommon/test/layerTests/FullyConnectedTestImpl.cpp index 5555772c5a..f7519a73bc 100644 --- a/src/backends/backendsCommon/test/layerTests/FullyConnectedTestImpl.cpp +++ b/src/backends/backendsCommon/test/layerTests/FullyConnectedTestImpl.cpp @@ -1,5 +1,5 @@ // -// Copyright © 2017 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2017,2022 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // @@ -44,20 +44,11 @@ LayerTestResult SimpleFullyConnectedTestImpl( armnn::FullyConnectedQueueDescriptor data; armnn::WorkloadInfo info; - armnn::ScopedTensorHandle weightsTensor(weightsTensorInfo); - armnn::ScopedTensorHandle biasTensor(biasesTensorInfo); - - AllocateAndCopyDataToITensorHandle(&weightsTensor, weights.data()); - AllocateAndCopyDataToITensorHandle(&biasTensor, bias.data()); AddInputToWorkload(data, info, inputTensorInfo, input0Handle.get()); AddInputToWorkload(data, info, weightsTensorInfo, input1Handle.get()); AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); - // Need to set as layer members will be null when creating the workload because the optimization hasn't been run. - data.m_Weight = &weightsTensor; - data.m_Bias = &biasTensor; - data.m_Parameters.m_BiasEnabled = biasEnabled; data.m_Parameters.m_TransposeWeightMatrix = transposeWeights; data.m_Parameters.m_ConstantWeights = constantWeights; -- cgit v1.2.1