ArmNN  NotReleased
ElementwiseTestImpl.hpp File Reference

Go to the source code of this file.

Functions

template<typename DescriptorType >
std::unique_ptr< armnn::IWorkloadCreateWorkload (const armnn::IWorkloadFactory &workloadFactory, const armnn::WorkloadInfo &info, const DescriptorType &descriptor)
 
template<std::size_t NumDims, typename Descriptor , armnn::DataType ArmnnTypeInput, armnn::DataType ArmnnTypeOutput, typename TInput = armnn::ResolveType<ArmnnTypeInput>, typename TOutput = armnn::ResolveType<ArmnnTypeOutput>>
LayerTestResult< TOutput, NumDims > ElementwiseTestHelper (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const unsigned int shape0[NumDims], std::vector< TInput > values0, float quantScale0, int quantOffset0, const unsigned int shape1[NumDims], std::vector< TInput > values1, float quantScale1, int quantOffset1, const unsigned int outShape[NumDims], std::vector< TOutput > outValues, float outQuantScale, int outQuantOffset)
 
template<std::size_t NumDims, typename Descriptor , armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, NumDims > ElementwiseTestHelper (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const unsigned int shape0[NumDims], std::vector< T > values0, float quantScale0, int quantOffset0, const unsigned int shape1[NumDims], std::vector< T > values1, float quantScale1, int quantOffset1, const unsigned int outShape[NumDims], std::vector< T > outValues, float outQuantScale, int outQuantOffset)
 
template<std::size_t NumDims, typename Descriptor , armnn::DataType ArmnnTypeInput, armnn::DataType ArmnnTypeOutput, typename TInput = armnn::ResolveType<ArmnnTypeInput>, typename TOutput = armnn::ResolveType<ArmnnTypeOutput>>
LayerTestResult< TOutput, NumDims > ElementwiseTestHelper (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const unsigned int shape0[NumDims], std::vector< TInput > values0, const unsigned int shape1[NumDims], std::vector< TInput > values1, const unsigned int outShape[NumDims], std::vector< TOutput > outValues, float quantScale=1.0f, int quantOffset=0)
 
template<std::size_t NumDims, typename Descriptor , armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, NumDims > ElementwiseTestHelper (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const unsigned int shape0[NumDims], std::vector< T > values0, const unsigned int shape1[NumDims], std::vector< T > values1, const unsigned int outShape[NumDims], std::vector< T > outValues, float quantScale=1.0f, int quantOffset=0)
 

Function Documentation

◆ CreateWorkload()

std::unique_ptr<armnn::IWorkload> CreateWorkload ( const armnn::IWorkloadFactory workloadFactory,
const armnn::WorkloadInfo info,
const DescriptorType &  descriptor 
)

Definition at line 27 of file ElementwiseTestImpl.hpp.

Referenced by Layer::SetBackendId().

31 {
32  return CreateWorkload(workloadFactory, info, descriptor);
33 }
std::unique_ptr< armnn::IWorkload > CreateWorkload(const armnn::IWorkloadFactory &workloadFactory, const armnn::WorkloadInfo &info, const DescriptorType &descriptor)

◆ ElementwiseTestHelper() [1/4]

LayerTestResult<TOutput, NumDims> ElementwiseTestHelper ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const unsigned int  shape0[NumDims],
std::vector< TInput >  values0,
float  quantScale0,
int  quantOffset0,
const unsigned int  shape1[NumDims],
std::vector< TInput >  values1,
float  quantScale1,
int  quantOffset1,
const unsigned int  outShape[NumDims],
std::vector< TOutput >  outValues,
float  outQuantScale,
int  outQuantOffset 
)

Definition at line 41 of file ElementwiseTestImpl.hpp.

References armnn::Boolean, LayerTestResult< T, n >::compareBoolean, CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreateTensorHandle(), LayerTestResult< T, n >::output, LayerTestResult< T, n >::outputExpected, and TensorInfo::SetQuantizationScale().

56 {
57  armnn::TensorInfo inputTensorInfo0{NumDims, shape0, ArmnnTypeInput};
58  armnn::TensorInfo inputTensorInfo1{NumDims, shape1, ArmnnTypeInput};
59  armnn::TensorInfo outputTensorInfo{NumDims, outShape, ArmnnTypeOutput};
60 
61  auto input0 = MakeTensor<TInput, NumDims>(inputTensorInfo0, values0);
62  auto input1 = MakeTensor<TInput, NumDims>(inputTensorInfo1, values1);
63 
64  inputTensorInfo0.SetQuantizationScale(quantScale0);
65  inputTensorInfo0.SetQuantizationOffset(quantOffset0);
66 
67  inputTensorInfo1.SetQuantizationScale(quantScale1);
68  inputTensorInfo1.SetQuantizationOffset(quantOffset1);
69 
70  outputTensorInfo.SetQuantizationScale(outQuantScale);
71  outputTensorInfo.SetQuantizationOffset(outQuantOffset);
72 
73  LayerTestResult<TOutput, NumDims> ret(outputTensorInfo);
74 
75  if(ArmnnTypeOutput == armnn::DataType::Boolean)
76  {
77  ret.compareBoolean = true;
78  }
79 
80  std::unique_ptr<armnn::ITensorHandle> inputHandle0 = workloadFactory.CreateTensorHandle(inputTensorInfo0);
81  std::unique_ptr<armnn::ITensorHandle> inputHandle1 = workloadFactory.CreateTensorHandle(inputTensorInfo1);
82  std::unique_ptr<armnn::ITensorHandle> outputHandle = workloadFactory.CreateTensorHandle(outputTensorInfo);
83 
84  Descriptor data;
86  AddInputToWorkload(data, info, inputTensorInfo0, inputHandle0.get());
87  AddInputToWorkload(data, info, inputTensorInfo1, inputHandle1.get());
88  AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
89  auto workload = CreateWorkload<Descriptor>(workloadFactory, info, data);
90 
91  inputHandle0->Allocate();
92  inputHandle1->Allocate();
93  outputHandle->Allocate();
94 
95  CopyDataToITensorHandle(inputHandle0.get(), input0.origin());
96  CopyDataToITensorHandle(inputHandle1.get(), input1.origin());
97 
98  workload->PostAllocationConfigure();
99  ExecuteWorkload(*workload, memoryManager);
100 
101  CopyDataFromITensorHandle(ret.output.origin(), outputHandle.get());
102 
103  ret.outputExpected = MakeTensor<TOutput, NumDims>(outputTensorInfo, outValues);
104  return ret;
105 }
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo, const bool IsMemoryManaged=true) const =0
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:259

◆ ElementwiseTestHelper() [2/4]

LayerTestResult<T, NumDims> ElementwiseTestHelper ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const unsigned int  shape0[NumDims],
std::vector< T >  values0,
float  quantScale0,
int  quantOffset0,
const unsigned int  shape1[NumDims],
std::vector< T >  values1,
float  quantScale1,
int  quantOffset1,
const unsigned int  outShape[NumDims],
std::vector< T >  outValues,
float  outQuantScale,
int  outQuantOffset 
)

Definition at line 111 of file ElementwiseTestImpl.hpp.

126 {
127  return ElementwiseTestHelper<NumDims, Descriptor, ArmnnType, ArmnnType>(
128  workloadFactory,
129  memoryManager,
130  shape0,
131  values0,
132  quantScale0,
133  quantOffset0,
134  shape1,
135  values1,
136  quantScale1,
137  quantOffset1,
138  outShape,
139  outValues,
140  outQuantScale,
141  outQuantOffset);
142 }

◆ ElementwiseTestHelper() [3/4]

LayerTestResult<TOutput, NumDims> ElementwiseTestHelper ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const unsigned int  shape0[NumDims],
std::vector< TInput >  values0,
const unsigned int  shape1[NumDims],
std::vector< TInput >  values1,
const unsigned int  outShape[NumDims],
std::vector< TOutput >  outValues,
float  quantScale = 1.0f,
int  quantOffset = 0 
)

Definition at line 150 of file ElementwiseTestImpl.hpp.

161 {
162  return ElementwiseTestHelper<NumDims, Descriptor, ArmnnTypeInput, ArmnnTypeOutput>(
163  workloadFactory,
164  memoryManager,
165  shape0,
166  values0,
167  quantScale,
168  quantOffset,
169  shape1,
170  values1,
171  quantScale,
172  quantOffset,
173  outShape,
174  outValues,
175  quantScale,
176  quantOffset);
177 }

◆ ElementwiseTestHelper() [4/4]

LayerTestResult<T, NumDims> ElementwiseTestHelper ( armnn::IWorkloadFactory workloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtr memoryManager,
const unsigned int  shape0[NumDims],
std::vector< T >  values0,
const unsigned int  shape1[NumDims],
std::vector< T >  values1,
const unsigned int  outShape[NumDims],
std::vector< T >  outValues,
float  quantScale = 1.0f,
int  quantOffset = 0 
)

Definition at line 183 of file ElementwiseTestImpl.hpp.

194 {
195  return ElementwiseTestHelper<NumDims, Descriptor, ArmnnType, ArmnnType>(
196  workloadFactory,
197  memoryManager,
198  shape0,
199  values0,
200  shape1,
201  values1,
202  outShape,
203  outValues,
204  quantScale,
205  quantOffset);
206 }