31 const std::vector<T>& paramsData,
32 const std::vector<int32_t>& indicesData,
33 const std::vector<T>& outputData)
39 std::unique_ptr<armnn::ITensorHandle> paramsHandle = tensorHandleFactory.
CreateTensorHandle(paramsInfo);
40 std::unique_ptr<armnn::ITensorHandle> indicesHandle = tensorHandleFactory.
CreateTensorHandle(indicesInfo);
41 std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.
CreateTensorHandle(outputInfo);
45 AddInputToWorkload(data, info, paramsInfo, paramsHandle.get());
46 AddInputToWorkload(data, info, indicesInfo, indicesHandle.get());
47 AddOutputToWorkload(data, info, outputInfo, outputHandle.get());
49 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.
CreateGather(data, info);
51 paramsHandle->Allocate();
52 indicesHandle->Allocate();
53 outputHandle->Allocate();
64 outputHandle->GetShape(),
68 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
69 struct GatherTestHelper
80 if (armnn::IsQuantizedType<T>())
87 const std::vector<T> params = std::vector<T>({ 1, 2, 3, 4, 5, 6, 7, 8 });
88 const std::vector<int32_t> indices = std::vector<int32_t>({ 0, 2, 1, 5 });
89 const std::vector<T> expectedOutput = std::vector<T>({ 1, 3, 2, 6 });
91 return GatherTestImpl<ArmnnType, T, 1, 1, 1>(
112 if (armnn::IsQuantizedType<T>())
120 const std::vector<T> params = std::vector<T>({ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 });
121 const std::vector<int32_t> indices = std::vector<int32_t>({ 1, 3, 4 });
122 const std::vector<T> expectedOutput = std::vector<T>({ 3, 4, 7, 8, 9, 10 });
124 return GatherTestImpl<ArmnnType, T, 2, 1, 2>(
145 if (armnn::IsQuantizedType<T>())
153 const std::vector<T> params =
165 const std::vector<int32_t> indices = { 1, 2, 1, 2, 1, 0 };
167 const std::vector<T> expectedOutput =
184 return GatherTestImpl<ArmnnType, T, 3, 2, 4>(
198 struct GatherTestHelper<
armnn::DataType::Float16, T>
205 using namespace half_float::literal;
211 const std::vector<T> params = std::vector<T>({ 1._h, 2._h, 3._h, 4._h, 5._h, 6._h, 7._h, 8._h });
212 const std::vector<int32_t> indices = std::vector<int32_t>({ 0, 2, 1, 5 });
213 const std::vector<T> expectedOutput = std::vector<T>({ 1._h, 3._h, 2._h, 6._h });
215 return GatherTestImpl<armnn::DataType::Float16, T, 1, 1, 1>(
232 using namespace half_float::literal;
238 const std::vector<T> params = std::vector<T>({ 1._h, 2._h, 3._h, 4._h, 5._h, 6._h, 7._h, 8._h, 9._h, 10._h });
240 const std::vector<int32_t> indices = std::vector<int32_t>({ 1, 3, 4 });
241 const std::vector<T> expectedOutput = std::vector<T>({ 3._h, 4._h, 7._h, 8._h, 9._h, 10._h });
243 return GatherTestImpl<armnn::DataType::Float16, T, 2, 1, 2>(
260 using namespace half_float::literal;
266 const std::vector<T> params =
278 const std::vector<int32_t> indices = { 1, 2, 1, 2, 1, 0 };
280 const std::vector<T> expectedOutput =
297 return GatherTestImpl<armnn::DataType::Float16, T, 3, 2, 4>(
317 return GatherTestHelper<armnn::DataType::Float32>::Gather1dParamsTestImpl(
318 workloadFactory, memoryManager, tensorHandleFactory);
326 return GatherTestHelper<armnn::DataType::Float16>::Gather1dParamsTestImpl(
327 workloadFactory, memoryManager, tensorHandleFactory);
335 return GatherTestHelper<armnn::DataType::QAsymmU8>::Gather1dParamsTestImpl(
336 workloadFactory, memoryManager, tensorHandleFactory);
344 return GatherTestHelper<armnn::DataType::QSymmS16>::Gather1dParamsTestImpl(
345 workloadFactory, memoryManager, tensorHandleFactory);
353 return GatherTestHelper<armnn::DataType::Signed32>::Gather1dParamsTestImpl(
354 workloadFactory, memoryManager, tensorHandleFactory);
362 return GatherTestHelper<armnn::DataType::Float32>::GatherMultiDimParamsTestImpl(
363 workloadFactory, memoryManager, tensorHandleFactory);
371 return GatherTestHelper<armnn::DataType::Float16>::GatherMultiDimParamsTestImpl(
372 workloadFactory, memoryManager, tensorHandleFactory);
380 return GatherTestHelper<armnn::DataType::QAsymmU8>::GatherMultiDimParamsTestImpl(
381 workloadFactory, memoryManager, tensorHandleFactory);
389 return GatherTestHelper<armnn::DataType::QSymmS16>::GatherMultiDimParamsTestImpl(
390 workloadFactory, memoryManager, tensorHandleFactory);
398 return GatherTestHelper<armnn::DataType::Signed32>::GatherMultiDimParamsTestImpl(
399 workloadFactory, memoryManager, tensorHandleFactory);
407 return GatherTestHelper<armnn::DataType::Float32>::GatherMultiDimParamsMultiDimIndicesTestImpl(
408 workloadFactory, memoryManager, tensorHandleFactory);
416 return GatherTestHelper<armnn::DataType::Float16>::GatherMultiDimParamsMultiDimIndicesTestImpl(
417 workloadFactory, memoryManager, tensorHandleFactory);
425 return GatherTestHelper<armnn::DataType::QAsymmU8>::GatherMultiDimParamsMultiDimIndicesTestImpl(
426 workloadFactory, memoryManager, tensorHandleFactory);
434 return GatherTestHelper<armnn::DataType::QSymmS16>::GatherMultiDimParamsMultiDimIndicesTestImpl(
435 workloadFactory, memoryManager, tensorHandleFactory);
443 return GatherTestHelper<armnn::DataType::Signed32>::GatherMultiDimParamsMultiDimIndicesTestImpl(
444 workloadFactory, memoryManager, tensorHandleFactory);
LayerTestResult< armnn::Half, 4 > GatherMultiDimParamsMultiDimIndicesFloat16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int32_t, 4 > GatherMultiDimParamsMultiDimIndicesInt32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
const TensorShape & GetShape() const
LayerTestResult< float, 1 > Gather1dParamsFloat32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int16_t, 2 > GatherMultiDimParamsInt16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
typename ResolveTypeImpl< DT >::Type ResolveType
LayerTestResult< uint8_t, 1 > Gather1dParamsUint8Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
Copyright (c) 2021 ARM Limited and Contributors.
void IgnoreUnused(Ts &&...)
LayerTestResult< float, 4 > GatherMultiDimParamsMultiDimIndicesFloat32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< armnn::Half, 1 > Gather1dParamsFloat16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
void SetQuantizationScale(float scale)
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
LayerTestResult< int32_t, 2 > GatherMultiDimParamsInt32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< armnn::Half, 2 > GatherMultiDimParamsFloat16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< float, 2 > GatherMultiDimParamsFloat32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
virtual std::unique_ptr< IWorkload > CreateGather(const GatherQueueDescriptor &descriptor, const WorkloadInfo &info) const
LayerTestResult< int16_t, 4 > GatherMultiDimParamsMultiDimIndicesInt16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
Contains information about TensorInfos of a layer.
void SetQuantizationOffset(int32_t offset)
LayerTestResult< uint8_t, 2 > GatherMultiDimParamsUint8Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int32_t, 1 > Gather1dParamsInt32Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< int16_t, 1 > Gather1dParamsInt16Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< uint8_t, 4 > GatherMultiDimParamsMultiDimIndicesUint8Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const =0
unsigned int GetNumElements() const
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)