// // Copyright © 2017 Arm Ltd. All rights reserved. // SPDX-License-Identifier: MIT // #include "EqualTestImpl.hpp" #include "ElementwiseTestImpl.hpp" template<> std::unique_ptr CreateWorkload( const armnn::IWorkloadFactory& workloadFactory, const armnn::WorkloadInfo& info, const armnn::EqualQueueDescriptor& descriptor) { return workloadFactory.CreateEqual(descriptor, info); } LayerTestResult EqualSimpleTest(armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int width = 2u; const unsigned int height = 2u; const unsigned int channelCount = 2u; const unsigned int batchSize = 2u; unsigned int shape[] = { batchSize, channelCount, height, width }; std::vector input0 = { 1.f, 1.f, 1.f, 1.f, 5.f, 5.f, 5.f, 5.f, 3.f, 3.f, 3.f, 3.f, 4.f, 4.f, 4.f, 4.f }; std::vector input1({ 1, 1, 1, 1, 3, 3, 3, 3, 5, 5, 5, 5, 4, 4, 4, 4 }); std::vector output({ 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1 }); return ElementwiseTestHelper<4, armnn::EqualQueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean>( workloadFactory, memoryManager, shape, input0, shape, input1, shape, output); } LayerTestResult EqualBroadcast1ElementTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { unsigned int shape0[] = { 1, 2, 2, 2 }; std::vector input0({ 1, 2, 3, 4, 5, 6, 7, 8}); unsigned int shape1[] = { 1, 1, 1, 1 }; std::vector input1({ 1 }); std::vector output({ 1, 0, 0, 0, 0, 0, 0, 0}); return ElementwiseTestHelper<4, armnn::EqualQueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult EqualBroadcast1DVectorTest( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 2, 2, 3 }; const unsigned int shape1[] = { 1, 1, 1, 3 }; std::vector input0({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); std::vector input1({ 1, 2, 3}); std::vector output({ 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }); return ElementwiseTestHelper<4, armnn::EqualQueueDescriptor, armnn::DataType::Float32, armnn::DataType::Boolean>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult EqualUint8Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { unsigned int shape[] = { 2, 2, 2, 2 }; // See dequantized values to the right. std::vector input0({ 1, 1, 1, 1, 6, 6, 6, 6, 3, 3, 3, 3, 7, 7, 7, 7 }); std::vector input1({ 2, 2, 2, 2, 6, 6, 6, 6, 3, 3, 3, 3, 5, 5, 5, 5 }); std::vector output({ 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0 }); return ElementwiseTestHelper<4, armnn::EqualQueueDescriptor, armnn::DataType::QuantisedAsymm8, armnn::DataType::Boolean>( workloadFactory, memoryManager, shape, input0, shape, input1, shape, output); } LayerTestResult EqualBroadcast1ElementUint8Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 2, 2, 3 }; const unsigned int shape1[] = { 1, 1, 1, 1 }; std::vector input0({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); std::vector input1({ 1 }); std::vector output({ 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }); return ElementwiseTestHelper<4, armnn::EqualQueueDescriptor, armnn::DataType::QuantisedAsymm8, armnn::DataType::Boolean>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); } LayerTestResult EqualBroadcast1DVectorUint8Test( armnn::IWorkloadFactory& workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr& memoryManager) { const unsigned int shape0[] = { 1, 2, 2, 3 }; const unsigned int shape1[] = { 1, 1, 1, 3 }; std::vector input0({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 }); std::vector input1({ 1, 1, 3}); std::vector output({ 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0 }); return ElementwiseTestHelper<4, armnn::EqualQueueDescriptor, armnn::DataType::QuantisedAsymm8, armnn::DataType::Boolean>( workloadFactory, memoryManager, shape0, input0, shape1, input1, shape0, output); }