diff options
author | Aron Virginas-Tar <Aron.Virginas-Tar@arm.com> | 2019-08-28 18:08:46 +0100 |
---|---|---|
committer | mike.kelly <mike.kelly@arm.com> | 2019-08-30 10:58:54 +0000 |
commit | 00d306e4db5153a4f4d280de4d4cf3e03788fefb (patch) | |
tree | 329c15f71c662e199a24dc0812bf95cb389ddbd8 /src/backends/backendsCommon/test/PermuteTestImpl.hpp | |
parent | 08b518687d2bf2683a2c5f571d3e76d71d67d048 (diff) | |
download | armnn-00d306e4db5153a4f4d280de4d4cf3e03788fefb.tar.gz |
IVGCVSW-3381 Break up LayerTests.hpp into more manageable files
Signed-off-by: Aron Virginas-Tar <Aron.Virginas-Tar@arm.com>
Change-Id: Icf39434f09fd340ad664cb3b97b8bee6d9da4838
Diffstat (limited to 'src/backends/backendsCommon/test/PermuteTestImpl.hpp')
-rw-r--r-- | src/backends/backendsCommon/test/PermuteTestImpl.hpp | 241 |
1 files changed, 0 insertions, 241 deletions
diff --git a/src/backends/backendsCommon/test/PermuteTestImpl.hpp b/src/backends/backendsCommon/test/PermuteTestImpl.hpp deleted file mode 100644 index 5f56fbde59..0000000000 --- a/src/backends/backendsCommon/test/PermuteTestImpl.hpp +++ /dev/null @@ -1,241 +0,0 @@ -// -// Copyright © 2017 Arm Ltd. All rights reserved. -// SPDX-License-Identifier: MIT -// -#pragma once - -#include "QuantizeHelper.hpp" -#include "WorkloadTestUtils.hpp" - -#include <armnn/ArmNN.hpp> -#include <armnn/Tensor.hpp> -#include <armnn/TypesUtils.hpp> - -#include <test/TensorHelpers.hpp> - -#include <backendsCommon/CpuTensorHandle.hpp> -#include <backendsCommon/IBackendInternal.hpp> -#include <backendsCommon/WorkloadFactory.hpp> - -template<typename T> -LayerTestResult<T, 4> SimplePermuteTestImpl( - armnn::IWorkloadFactory& workloadFactory, - const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager, - armnn::PermuteDescriptor descriptor, - armnn::TensorInfo inputTensorInfo, - armnn::TensorInfo outputTensorInfo, - const std::vector<T>& inputData, - const std::vector<T>& outputExpectedData) -{ - auto input = MakeTensor<T, 4>(inputTensorInfo, inputData); - - LayerTestResult<T, 4> ret(outputTensorInfo); - ret.outputExpected = MakeTensor<T, 4>(outputTensorInfo, outputExpectedData); - - std::unique_ptr<armnn::ITensorHandle> inputHandle = workloadFactory.CreateTensorHandle(inputTensorInfo); - std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo); - - armnn::PermuteQueueDescriptor data; - data.m_Parameters = descriptor; - armnn::WorkloadInfo info; - AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get()); - AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get()); - - std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePermute(data, info); - - inputHandle->Allocate(); - outputHandle->Allocate(); - - CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]); - - workload->Execute(); - - CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get()); - - return ret; -} - -template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> -LayerTestResult<T, 4> SimplePermuteTest( - armnn::IWorkloadFactory& workloadFactory, - const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) -{ - armnn::TensorInfo inputTensorInfo; - armnn::TensorInfo outputTensorInfo; - - unsigned int inputShape[] = { 1, 2, 2, 2 }; - unsigned int outputShape[] = { 1, 2, 2, 2 }; - - armnn::PermuteDescriptor descriptor; - descriptor.m_DimMappings = {0U, 3U, 1U, 2U}; - - inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType); - outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType); - - // Set quantization parameters if the requested type is a quantized type. - if(armnn::IsQuantizedType<T>()) - { - inputTensorInfo.SetQuantizationScale(0.5f); - inputTensorInfo.SetQuantizationOffset(5); - outputTensorInfo.SetQuantizationScale(0.5f); - outputTensorInfo.SetQuantizationOffset(5); - } - - std::vector<T> input = std::vector<T>( - { - 1, 2, - 3, 4, - 5, 6, - 7, 8 - }); - - std::vector<T> outputExpected = std::vector<T>( - { - 1, 5, 2, 6, - 3, 7, 4, 8 - }); - - return SimplePermuteTestImpl<T>(workloadFactory, memoryManager, - descriptor, inputTensorInfo, - outputTensorInfo, input, outputExpected); -} - -template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> -LayerTestResult<T, 4> PermuteValueSet1Test( - armnn::IWorkloadFactory& workloadFactory, - const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) -{ - armnn::TensorInfo inputTensorInfo; - armnn::TensorInfo outputTensorInfo; - - unsigned int inputShape[] = { 1, 2, 2, 3 }; - unsigned int outputShape[] = { 1, 3, 2, 2 }; - - armnn::PermuteDescriptor descriptor; - descriptor.m_DimMappings = {0U, 2U, 3U, 1U}; - - inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType); - outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType); - - // Set quantization parameters if the requested type is a quantized type. - if(armnn::IsQuantizedType<T>()) - { - inputTensorInfo.SetQuantizationScale(0.5f); - inputTensorInfo.SetQuantizationOffset(5); - outputTensorInfo.SetQuantizationScale(0.5f); - outputTensorInfo.SetQuantizationOffset(5); - } - - std::vector<T> input = std::vector<T>( - { - 1, 2, 3, - 11, 12, 13, - 21, 22, 23, - 31, 32, 33 - }); - - std::vector<T> outputExpected = std::vector<T>( - { - 1, 11, 21, 31, - 2, 12, 22, 32, - 3, 13, 23, 33 - }); - - return SimplePermuteTestImpl<T>(workloadFactory, memoryManager, - descriptor, inputTensorInfo, - outputTensorInfo, input, outputExpected); -} - -template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> -LayerTestResult<T, 4> PermuteValueSet2Test( - armnn::IWorkloadFactory& workloadFactory, - const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) -{ - armnn::TensorInfo inputTensorInfo; - armnn::TensorInfo outputTensorInfo; - - unsigned int inputShape[] = { 1, 3, 2, 2 }; - unsigned int outputShape[] = { 1, 2, 2, 3 }; - - armnn::PermuteDescriptor descriptor; - descriptor.m_DimMappings = {0U, 3U, 1U, 2U}; - - inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType); - outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType); - - // Set quantization parameters if the requested type is a quantized type. - if(armnn::IsQuantizedType<T>()) - { - inputTensorInfo.SetQuantizationScale(0.5f); - inputTensorInfo.SetQuantizationOffset(5); - outputTensorInfo.SetQuantizationScale(0.5f); - outputTensorInfo.SetQuantizationOffset(5); - } - - std::vector<T> input = std::vector<T>( - { - 1, 11, 21, 31, - 2, 12, 22, 32, - 3, 13, 23, 33 - }); - - std::vector<T> outputExpected = std::vector<T>( - { - 1, 2, 3, - 11, 12, 13, - 21, 22, 23, - 31, 32, 33, - }); - - return SimplePermuteTestImpl<T>(workloadFactory, memoryManager, - descriptor, inputTensorInfo, - outputTensorInfo, input, outputExpected); -} - -template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>> -LayerTestResult<T, 4> PermuteValueSet3Test( - armnn::IWorkloadFactory& workloadFactory, - const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) -{ - armnn::TensorInfo inputTensorInfo; - armnn::TensorInfo outputTensorInfo; - - unsigned int inputShape[] = { 1, 2, 3, 3 }; - unsigned int outputShape[] = { 1, 3, 2, 3 }; - - armnn::PermuteDescriptor descriptor; - descriptor.m_DimMappings = {0U, 2U, 3U, 1U}; - - inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType); - outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType); - - // Set quantization parameters if the requested type is a quantized type. - if(armnn::IsQuantizedType<T>()) - { - inputTensorInfo.SetQuantizationScale(0.5f); - inputTensorInfo.SetQuantizationOffset(5); - outputTensorInfo.SetQuantizationScale(0.5f); - outputTensorInfo.SetQuantizationOffset(5); - } - - std::vector<T> input = std::vector<T>( - { - 1, 2, 3, - 11, 12, 13, - 21, 22, 23, - 31, 32, 33, - 41, 42, 43, - 51, 52, 53 - }); - - std::vector<T> outputExpected = std::vector<T>( - { - 1, 11, 21, 31, 41, 51, - 2, 12, 22, 32, 42, 52, - 3, 13, 23, 33, 43, 53 - }); - - return SimplePermuteTestImpl<T>(workloadFactory, memoryManager, - descriptor, inputTensorInfo, - outputTensorInfo, input, outputExpected); -} |