18 template<armnn::DataType ArmnnType,
typename T, std::
size_t InputDim, std::
size_t OutputDim>
23 const unsigned int* inputShape,
24 const std::vector<float>& inputData,
25 const std::vector<unsigned int>& axis,
27 const unsigned int* outputShape,
28 const std::vector<float>& outputData,
37 inputTensorInfo.SetQuantizationScale(scale);
38 inputTensorInfo.SetQuantizationOffset(offset);
40 outputTensorInfo.SetQuantizationScale(scale);
41 outputTensorInfo.SetQuantizationOffset(offset);
43 auto input = MakeTensor<T, InputDim>(inputTensorInfo, ConvertToDataType<ArmnnType>(inputData, inputTensorInfo));
46 result.outputExpected = MakeTensor<T, OutputDim>(
47 outputTensorInfo, ConvertToDataType<ArmnnType>(outputData, outputTensorInfo));
49 std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.
CreateTensorHandle(inputTensorInfo);
50 std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.
CreateTensorHandle(outputTensorInfo);
56 AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
57 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
59 std::unique_ptr<armnn::IWorkload> workload = workloadFactory.
CreateMean(data, info);
61 inputHandle->Allocate();
62 outputHandle->Allocate();
66 workload->PostAllocationConfigure();
76 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
82 const unsigned int inputShape[] = { 3, 2 };
83 const unsigned int outputShape[] = { 1 };
85 std::vector<float> input({ 1.5f, 1.5f, 2.5f, 2.5f, 3.5f, 3.5f });
86 std::vector<float> output({ 2.5f });
88 return MeanTestHelper<ArmnnType, T, 2, 1>(
89 workloadFactory, memoryManager, tensorHandleFactory, inputShape, input, {},
false, outputShape, output);
92 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
98 const unsigned int inputShape[] = { 2, 3, 1, 2 };
99 const unsigned int outputShape[] = { 3, 1, 2 };
101 std::vector<float> input({ 1.5f, 2.5f, 3.5f, 4.5f, 5.5f, 6.5f, 1.5f, 2.5f, 3.5f, 4.5f, 5.5f, 6.5f });
102 std::vector<float> output({ 1.5f, 2.5f, 3.5f, 4.5f, 5.5f, 6.5f });
104 return MeanTestHelper<ArmnnType, T, 4, 3>(
105 workloadFactory, memoryManager, tensorHandleFactory, inputShape, input, { 0 },
false, outputShape, output);
108 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
114 const unsigned int inputShape[] = { 1, 1, 3, 2 };
115 const unsigned int outputShape[] = { 1, 1, 1, 2 };
117 std::vector<float> input({ 1.5f, 1.5f, 2.5f, 2.5f, 3.5f, 3.5f });
118 std::vector<float> output({ 2.5f, 2.5f });
120 return MeanTestHelper<ArmnnType, T, 4, 4>(
121 workloadFactory, memoryManager, tensorHandleFactory, inputShape, input, { 2 },
true, outputShape, output);
124 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
130 const unsigned int inputShape[] = { 2, 3, 1, 2 };
131 const unsigned int outputShape[] = { 1, 3, 1, 1 };
133 std::vector<float> input({ 1.5f, 2.5f, 3.5f, 4.5f, 5.5f, 6.5f, 1.5f, 2.5f, 3.5f, 4.5f, 5.5f, 6.5 });
134 std::vector<float> output({ 2.0f, 4.0f, 6.0f });
136 return MeanTestHelper<ArmnnType, T, 4, 4>(
137 workloadFactory, memoryManager, tensorHandleFactory,
138 inputShape, input, { 0, 3 },
true, outputShape, output);
141 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
147 const unsigned int inputShape[] = { 4, 3, 2 };
148 const unsigned int outputShape[] = { 2 };
150 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f,
151 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f });
152 std::vector<float> output({ 12.0f, 13.0f });
154 return MeanTestHelper<ArmnnType, T, 3, 1>(
155 workloadFactory, memoryManager, tensorHandleFactory,
156 inputShape, input, { 0, 1 },
false, outputShape, output);
159 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
165 const unsigned int inputShape[] = { 4, 3, 2 };
166 const unsigned int outputShape[] = { 1, 3, 1 };
168 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f, 10.0f, 11.0f, 12.0f, 13.0f, 14.0f,
169 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f });
170 std::vector<float> output({ 10.5f, 12.5f, 14.5f });
172 return MeanTestHelper<ArmnnType, T, 3, 3>(
173 workloadFactory, memoryManager, tensorHandleFactory,
174 inputShape, input, { 0, 2 },
true, outputShape, output);
177 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
183 const unsigned int inputShape[] = { 1, 2, 2, 1 };
184 const unsigned int outputShape[] = { 1, 2, 1 };
186 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f });
187 std::vector<float> output({ 1.5f, 3.5f });
189 return MeanTestHelper<ArmnnType, T, 4, 3>(
190 workloadFactory, memoryManager, tensorHandleFactory, inputShape, input, { 2 },
false, outputShape, output);
LayerTestResult< T, 4 > MeanKeepDimsTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< T, 4 > MeanMultipleDimsTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
LayerTestResult< T, 1 > MeanVts1Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
void IgnoreUnused(Ts &&...)
LayerDescriptor m_Parameters
std::vector< unsigned int > m_Axis
Values for the dimensions to reduce.
LayerTestResult< T, 3 > MeanVts2Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
bool m_KeepDims
Enable/disable keep dimensions. If true, then the reduced dimensions that are of length 1 are kept...
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
LayerTestResult< T, 3 > MeanVts3Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
LayerTestResult< T, 3 > MeanSimpleAxisTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
virtual std::unique_ptr< IWorkload > CreateMean(const MeanQueueDescriptor &descriptor, const WorkloadInfo &Info) const
Contains information about inputs and outputs to a layer.
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const =0
LayerTestResult< T, 1 > MeanSimpleTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)