diff options
Diffstat (limited to 'src/backends/backendsCommon/test/DepthwiseConvolution2dEndToEndTests.hpp')
-rw-r--r-- | src/backends/backendsCommon/test/DepthwiseConvolution2dEndToEndTests.hpp | 88 |
1 files changed, 50 insertions, 38 deletions
diff --git a/src/backends/backendsCommon/test/DepthwiseConvolution2dEndToEndTests.hpp b/src/backends/backendsCommon/test/DepthwiseConvolution2dEndToEndTests.hpp index 1f9b60a4f2..a2c369b692 100644 --- a/src/backends/backendsCommon/test/DepthwiseConvolution2dEndToEndTests.hpp +++ b/src/backends/backendsCommon/test/DepthwiseConvolution2dEndToEndTests.hpp @@ -1,5 +1,5 @@ // -// Copyright © 2022 Arm Ltd and Contributors. All rights reserved. +// Copyright © 2022, 2024 Arm Ltd and Contributors. All rights reserved. // SPDX-License-Identifier: MIT // #pragma once @@ -67,34 +67,34 @@ void DepthwiseConvolution2dEndToEnd(const std::vector<armnn::BackendId>& backend unsigned int kernelWidth = 3; unsigned int outputHeight = inputHeight - kernelHeight + 1 + 2; - unsigned int outputWidth = (inputWidth - kernelWidth + 1)/2; + unsigned int outputWidth = inputWidth - kernelWidth + 1; unsigned int outputChannels = inputChannels * depthMultiplier; unsigned int outputBatchSize = inputBatchSize; - TensorInfo inputInfo({ inputBatchSize, inputChannels, inputHeight, inputWidth }, ArmnnType, qScale, qOffset, true); - TensorInfo outputInfo({ outputBatchSize, outputChannels, outputHeight, outputWidth }, ArmnnType, qScale, qOffset); - TensorInfo weightsInfo({1, kernelHeight, kernelWidth, outputChannels}, ArmnnType, qScale, qOffset, true); - TensorInfo biasesInfo({outputChannels}, ArmnnBType, qScale * qScale, 0, true); + TensorInfo inputInfo({ inputBatchSize, inputHeight, inputWidth, inputChannels }, ArmnnType, qScale, qOffset, true); + TensorInfo outputInfo({ outputBatchSize, outputHeight, outputWidth, outputChannels }, ArmnnType, qScale, qOffset); + TensorInfo weightsInfo({ 1, kernelHeight, kernelWidth, outputChannels }, ArmnnType, qScale, qOffset, true); + TensorInfo biasesInfo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1.0f, 5.0f, 8.0f, 1.0f, -1.0f, 5.0f, 8.0f, 1.0f, -1.0f + }; DepthwiseConvolution2dDescriptor descriptor; descriptor.m_PadLeft = 0; descriptor.m_PadRight = 0; descriptor.m_PadTop = 1; - descriptor.m_PadBottom = 0; - descriptor.m_StrideX = 2; + descriptor.m_PadBottom = 1; + descriptor.m_StrideX = 1; descriptor.m_StrideY = 1; descriptor.m_BiasEnabled = true; descriptor.m_DataLayout = dataLayout; - // Permute input and output if NCDHW. + // Permute input if NCHW, the original input and output are in NHWC format. if (dataLayout == DataLayout::NCHW) { PermuteTensorNhwcToNchw(inputInfo, inputData); |