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 = ConvertToDataType<ArmnnType>(inputData, inputTensorInfo);
45 std::vector<T> actualOutput(outputTensorInfo.GetNumElements());
46 std::vector<T> expectedOutput = ConvertToDataType<ArmnnType>(outputData, outputTensorInfo);
48 std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.
CreateTensorHandle(inputTensorInfo);
49 std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.
CreateTensorHandle(outputTensorInfo);
55 AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
56 AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
60 inputHandle->Allocate();
61 outputHandle->Allocate();
65 workload->PostAllocationConfigure();
72 outputHandle->GetShape(),
73 outputTensorInfo.GetShape());
78 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
84 const unsigned int inputShape[] = { 3, 2 };
85 const unsigned int outputShape[] = { 1 };
87 std::vector<float> input({ 1.5f, 1.5f, 2.5f, 2.5f, 3.5f, 3.5f });
88 std::vector<float> output({ 2.5f });
90 return MeanTestHelper<ArmnnType, T, 2, 1>(
91 workloadFactory, memoryManager, tensorHandleFactory, inputShape, input, {},
false, outputShape, output);
94 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
100 const unsigned int inputShape[] = { 2, 3, 1, 2 };
101 const unsigned int outputShape[] = { 3, 1, 2 };
103 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 });
104 std::vector<float> output({ 1.5f, 2.5f, 3.5f, 4.5f, 5.5f, 6.5f });
106 return MeanTestHelper<ArmnnType, T, 4, 3>(
107 workloadFactory, memoryManager, tensorHandleFactory, inputShape, input, { 0 },
false, outputShape, output);
110 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
116 const unsigned int inputShape[] = { 1, 1, 3, 2 };
117 const unsigned int outputShape[] = { 1, 1, 1, 2 };
119 std::vector<float> input({ 1.5f, 1.5f, 2.5f, 2.5f, 3.5f, 3.5f });
120 std::vector<float> output({ 2.5f, 2.5f });
122 return MeanTestHelper<ArmnnType, T, 4, 4>(
123 workloadFactory, memoryManager, tensorHandleFactory, inputShape, input, { 2 },
true, outputShape, output);
126 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
132 const unsigned int inputShape[] = { 2, 3, 1, 2 };
133 const unsigned int outputShape[] = { 1, 3, 1, 1 };
135 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 });
136 std::vector<float> output({ 2.0f, 4.0f, 6.0f });
138 return MeanTestHelper<ArmnnType, T, 4, 4>(
139 workloadFactory, memoryManager, tensorHandleFactory,
140 inputShape, input, { 0, 3 },
true, outputShape, output);
143 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
149 const unsigned int inputShape[] = { 4, 3, 2 };
150 const unsigned int outputShape[] = { 2 };
152 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,
153 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f });
154 std::vector<float> output({ 12.0f, 13.0f });
156 return MeanTestHelper<ArmnnType, T, 3, 1>(
157 workloadFactory, memoryManager, tensorHandleFactory,
158 inputShape, input, { 0, 1 },
false, outputShape, output);
161 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
167 const unsigned int inputShape[] = { 4, 3, 2 };
168 const unsigned int outputShape[] = { 1, 3, 1 };
170 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,
171 15.0f, 16.0f, 17.0f, 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f });
172 std::vector<float> output({ 10.5f, 12.5f, 14.5f });
174 return MeanTestHelper<ArmnnType, T, 3, 3>(
175 workloadFactory, memoryManager, tensorHandleFactory,
176 inputShape, input, { 0, 2 },
true, outputShape, output);
179 template<armnn::DataType ArmnnType,
typename T = armnn::ResolveType<ArmnnType>>
185 const unsigned int inputShape[] = { 1, 2, 2, 1 };
186 const unsigned int outputShape[] = { 1, 2, 1 };
188 std::vector<float> input({ 1.0f, 2.0f, 3.0f, 4.0f });
189 std::vector<float> output({ 1.5f, 3.5f });
191 return MeanTestHelper<ArmnnType, T, 4, 3>(
192 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
void CopyDataFromITensorHandle(void *mem, const armnn::ITensorHandle *tensorHandle)
LayerTestResult< T, 3 > MeanVts3Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)
LayerTestResult< T, 3 > MeanSimpleAxisTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
Contains information about TensorInfos of a layer.
virtual std::unique_ptr< IWorkload > CreateWorkload(LayerType type, const QueueDescriptor &descriptor, const WorkloadInfo &info) const
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)