// // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // #include "SubtractionTestImpl.hpp" #include "ElementwiseTestImpl.hpp" template<> std::unique_ptr CreateWorkload( const armnn::IWorkloadFactory& workloadFactory, const armnn::WorkloadInfo& info, const armnn::SubtractionQueueDescriptor& descriptor) { return workloadFactory.CreateSubtraction(descriptor, info); } LayerTestResult SubtractionUint8Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 2, 2 }; std::vector input0 = { 10, 12, 14, 16 }; std::vector input1 = { 1, 2, 1, 2 }; std::vector output = { 3, 3, 5, 5 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QAsymmU8>( workloadFactory, memoryManager, shape0, input0, 0.5f, 2, shape1, input1, 1.0f, 0, shape0, output, 1.0f, 0); } LayerTestResult SubtractionBroadcast1ElementUint8Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 1, 1 }; std::vector input0 = { 10, 12, 14, 16 }; std::vector input1 = { 2 }; std::vector output = { 5, 6, 7, 8 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QAsymmU8>( workloadFactory, memoryManager, shape0, input0, 0.5f, 2, shape1, input1, 1.0f, 0, shape0, output, 1.0f, 3); } LayerTestResult SubtractionBroadcastUint8Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 2, 1 }; std::vector input0 = { 10, 12, 14, 16 }; std::vector input1 = { 2, 1 }; std::vector output = { 8, 11, 12, 15 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QAsymmU8>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult SubtractionTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 2, 2 }; std::vector input0 = { 1, 2, 3, 4 }; std::vector input1 = { 1, -1, 0, 2 }; std::vector output = { 0, 3, 3, 2 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float32>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult SubtractionBroadcast1ElementTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 1, 1 }; std::vector input0 = { 1, 2, 3, 4 }; std::vector input1 = { 10 }; std::vector output = { -9, -8, -7, -6 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float32>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult SubtractionBroadcastTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 1, 2 }; std::vector input0 = { 1, 2, 3, 4 }; std::vector input1 = { 10, -5 }; std::vector output = { -9, 7, -7, 9 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float32>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult SubtractionFloat16Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { using namespace half_float::literal; const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 2, 2 }; std::vector input0 = { 1._h, 2._h, 3._h, 4._h }; std::vector input1 = { 1._h, -1._h, 0._h, 2._h }; std::vector output = { 0._h, 3._h, 3._h, 2._h }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float16>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult SubtractionBroadcast1ElementFloat16Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { using namespace half_float::literal; const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 1, 1 }; std::vector input0 = { 1._h, 2._h, 3._h, 4._h }; std::vector input1 = { 10._h }; std::vector output = { -9._h, -8._h, -7._h, -6._h }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float16>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult SubtractionBroadcastFloat16Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { using namespace half_float::literal; const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 1, 2 }; std::vector input0 = { 1._h, 2._h, 3._h, 4._h }; std::vector input1 = { 10._h, -5._h }; std::vector output = { -9._h, 7._h, -7._h, 9._h }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Float16>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult SubtractionInt16Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape[] = { 1, 1, 2, 2 }; std::vector input0 = { 10, 12, 14, 16 }; std::vector input1 = { 1, 2, 1, 2 }; std::vector output = { 3, 3, 5, 5 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QSymmS16>( workloadFactory, memoryManager, shape, input0, 0.5f, 0, shape, input1, 1.0f, 0, shape, output, 1.0f, 0); } LayerTestResult SubtractionBroadcast1ElementInt16Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 1, 1 }; std::vector input0 = { 10, 12, 14, 16 }; std::vector input1 = { 2 }; std::vector output = { 3, 4, 5, 6 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QSymmS16>( workloadFactory, memoryManager, shape0, input0, 0.5f, 0, shape1, input1, 1.0f, 0, shape0, output, 1.0f, 0); } LayerTestResult SubtractionBroadcastInt16Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 2, 1 }; std::vector input0 = { 10, 12, 14, 16 }; std::vector input1 = { 2, 1 }; std::vector output = { 8, 11, 12, 15 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::QSymmS16>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult SubtractionInt32Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape[] = { 1, 1, 2, 2 }; std::vector input0 = { 5, 6, 7, 8 }; std::vector input1 = { 1, 2, 1, 2 }; std::vector output = { 4, 4, 6, 6 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Signed32>( workloadFactory, memoryManager, shape, input0, 1.0f, 0, shape, input1, 1.0f, 0, shape, output, 1.0f, 0); } LayerTestResult SubtractionBroadcast1ElementInt32Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 1, 1 }; std::vector input0 = { 5, 6, 7, 8 }; std::vector input1 = { 2 }; std::vector output = { 3, 4, 5, 6 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Signed32>( workloadFactory, memoryManager, shape0, input0, 1.0f, 0, shape1, input1, 1.0f, 0, shape0, output, 1.0f, 0); } LayerTestResult SubtractionBroadcastInt32Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 1, 2, 2 }; const unsigned int shape1[] = { 1, 1, 2, 1 }; std::vector input0 = { 10, 12, 14, 16 }; std::vector input1 = { 2, 1 }; std::vector output = { 8, 11, 12, 15 }; return ElementwiseTestHelper<4, armnn::SubtractionQueueDescriptor, armnn::DataType::Signed32>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); }