From fd627ffaec8fd8801d980b4c91ee7c0607ab6aaf Mon Sep 17 00:00:00 2001 From: Jan Eilers Date: Thu, 25 Feb 2021 17:44:00 +0000 Subject: IVGCVSW-5687 Update Doxygen Docu * Update Doxygen Documentation for 21.02 release Signed-off-by: Jan Eilers Change-Id: I9ed2f9caab038836ea99d7b378d7899fe431a4e5 --- 21.02/_transpose_test_impl_8hpp_source.xhtml | 141 +++++++++++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 21.02/_transpose_test_impl_8hpp_source.xhtml (limited to '21.02/_transpose_test_impl_8hpp_source.xhtml') diff --git a/21.02/_transpose_test_impl_8hpp_source.xhtml b/21.02/_transpose_test_impl_8hpp_source.xhtml new file mode 100644 index 0000000000..b040b8d996 --- /dev/null +++ b/21.02/_transpose_test_impl_8hpp_source.xhtml @@ -0,0 +1,141 @@ + + + + + + + + + + + + + +ArmNN: src/backends/backendsCommon/test/layerTests/TransposeTestImpl.hpp Source File + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  21.02 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+
+
TransposeTestImpl.hpp
+
+
+Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <ResolveType.hpp>
9 
10 
13 
16 
17 #include <test/TensorHelpers.hpp>
18 
19 template<typename T>
21  armnn::IWorkloadFactory& workloadFactory,
23  const armnn::ITensorHandleFactory& tensorHandleFactory,
24  armnn::TransposeDescriptor descriptor,
25  armnn::TensorInfo inputTensorInfo,
26  armnn::TensorInfo outputTensorInfo,
27  const std::vector<T>& inputData,
28  const std::vector<T>& outputExpectedData)
29 {
30  IgnoreUnused(memoryManager);
31  auto input = MakeTensor<T, 4>(inputTensorInfo, inputData);
32 
33  LayerTestResult<T, 4> ret(outputTensorInfo);
34  ret.outputExpected = MakeTensor<T, 4>(outputTensorInfo, outputExpectedData);
35 
36  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
37  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
38 
40  data.m_Parameters = descriptor;
42  AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
43  AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
44 
45  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreateTranspose(data, info);
46 
47  inputHandle->Allocate();
48  outputHandle->Allocate();
49 
50  CopyDataToITensorHandle(inputHandle.get(), &input[0][0][0][0]);
51 
52  workload->Execute();
53 
54  CopyDataFromITensorHandle(&ret.output[0][0][0][0], outputHandle.get());
55 
56  return ret;
57 }
58 
59 template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
61  armnn::IWorkloadFactory& workloadFactory,
63  const armnn::ITensorHandleFactory& tensorHandleFactory)
64 {
65  armnn::TensorInfo inputTensorInfo;
66  armnn::TensorInfo outputTensorInfo;
67 
68  unsigned int inputShape[] = { 1, 2, 2, 2 };
69  unsigned int outputShape[] = { 1, 2, 2, 2 };
70 
71  armnn::TransposeDescriptor descriptor;
72  descriptor.m_DimMappings = {0U, 2U, 3U, 1U};
73 
74  inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType);
75  outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType);
76 
77  // Set quantization parameters if the requested type is a quantized type.
78  float qScale = 0.5f;
79  int32_t qOffset = 5;
80  if(armnn::IsQuantizedType<T>())
81  {
82  inputTensorInfo.SetQuantizationScale(qScale);
83  inputTensorInfo.SetQuantizationOffset(qOffset);
84  outputTensorInfo.SetQuantizationScale(qScale);
85  outputTensorInfo.SetQuantizationOffset(qOffset);
86  }
87 
88  std::vector<T> input = armnnUtils::QuantizedVector<T>(
89  {
90  1, 2,
91  3, 4,
92  5, 6,
93  7, 8
94  },
95  qScale, qOffset);
96 
97  std::vector<T> outputExpected = armnnUtils::QuantizedVector<T>(
98  {
99  1, 5, 2, 6,
100  3, 7, 4, 8
101  },
102  qScale, qOffset);
103 
104  return SimpleTransposeTestImpl(workloadFactory, memoryManager, tensorHandleFactory,
105  descriptor, inputTensorInfo,
106  outputTensorInfo, input, outputExpected);
107 }
108 
109 template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
111  armnn::IWorkloadFactory& workloadFactory,
113  const armnn::ITensorHandleFactory& tensorHandleFactory)
114 {
115  armnn::TensorInfo inputTensorInfo;
116  armnn::TensorInfo outputTensorInfo;
117 
118  unsigned int inputShape[] = { 1, 2, 2, 3 };
119  unsigned int outputShape[] = { 1, 3, 2, 2 };
120 
121  armnn::TransposeDescriptor descriptor;
122  descriptor.m_DimMappings = {0U, 3U, 1U, 2U};
123 
124  inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType);
125  outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType);
126 
127  // Set quantization parameters if the requested type is a quantized type.
128  float qScale = 0.5f;
129  int32_t qOffset = 5;
130  if(armnn::IsQuantizedType<T>())
131  {
132  inputTensorInfo.SetQuantizationScale(qScale);
133  inputTensorInfo.SetQuantizationOffset(qOffset);
134  outputTensorInfo.SetQuantizationScale(qScale);
135  outputTensorInfo.SetQuantizationOffset(qOffset);
136  }
137 
138  std::vector<T> input = armnnUtils::QuantizedVector<T>(
139  {
140  1, 2, 3,
141  11, 12, 13,
142  21, 22, 23,
143  31, 32, 33
144  },
145  qScale, qOffset);
146 
147  std::vector<T> outputExpected = armnnUtils::QuantizedVector<T>(
148  {
149  1, 11, 21, 31,
150  2, 12, 22, 32,
151  3, 13, 23, 33
152  },
153  qScale, qOffset);
154 
155  return SimpleTransposeTestImpl<T>(workloadFactory, memoryManager, tensorHandleFactory,
156  descriptor, inputTensorInfo,
157  outputTensorInfo, input, outputExpected);
158 }
159 
160 template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
162  armnn::IWorkloadFactory& workloadFactory,
164  const armnn::ITensorHandleFactory& tensorHandleFactory)
165 {
166  armnn::TensorInfo inputTensorInfo;
167  armnn::TensorInfo outputTensorInfo;
168 
169  unsigned int inputShape[] = { 1, 3, 2, 2 };
170  unsigned int outputShape[] = { 1, 2, 2, 3 };
171 
172  armnn::TransposeDescriptor descriptor;
173  descriptor.m_DimMappings = {0U, 2U, 3U, 1U};
174 
175  inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType);
176  outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType);
177 
178  // Set quantization parameters if the requested type is a quantized type.
179  float qScale = 0.5f;
180  int32_t qOffset = 5;
181  if(armnn::IsQuantizedType<T>())
182  {
183  inputTensorInfo.SetQuantizationScale(qScale);
184  inputTensorInfo.SetQuantizationOffset(qOffset);
185  outputTensorInfo.SetQuantizationScale(qScale);
186  outputTensorInfo.SetQuantizationOffset(qOffset);
187  }
188 
189  std::vector<T> input = armnnUtils::QuantizedVector<T>(
190  {
191  1, 11, 21, 31,
192  2, 12, 22, 32,
193  3, 13, 23, 33
194  },
195  qScale, qOffset);
196 
197  std::vector<T> outputExpected = armnnUtils::QuantizedVector<T>(
198  {
199  1, 2, 3,
200  11, 12, 13,
201  21, 22, 23,
202  31, 32, 33,
203  },
204  qScale, qOffset);
205 
206  return SimpleTransposeTestImpl<T>(workloadFactory, memoryManager, tensorHandleFactory,
207  descriptor, inputTensorInfo,
208  outputTensorInfo, input, outputExpected);
209 }
210 
211 template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
213  armnn::IWorkloadFactory& workloadFactory,
215  const armnn::ITensorHandleFactory& tensorHandleFactory)
216 {
217  armnn::TensorInfo inputTensorInfo;
218  armnn::TensorInfo outputTensorInfo;
219 
220  unsigned int inputShape[] = { 1, 2, 3, 3 };
221  unsigned int outputShape[] = { 1, 3, 2, 3 };
222 
223  armnn::TransposeDescriptor descriptor;
224  descriptor.m_DimMappings = {0U, 3U, 1U, 2U};
225 
226  inputTensorInfo = armnn::TensorInfo(4, inputShape, ArmnnType);
227  outputTensorInfo = armnn::TensorInfo(4, outputShape, ArmnnType);
228 
229  // Set quantization parameters if the requested type is a quantized type.
230  float qScale = 0.5f;
231  int32_t qOffset = 5;
232  if(armnn::IsQuantizedType<T>())
233  {
234  inputTensorInfo.SetQuantizationScale(qScale);
235  inputTensorInfo.SetQuantizationOffset(qOffset);
236  outputTensorInfo.SetQuantizationScale(qScale);
237  outputTensorInfo.SetQuantizationOffset(qOffset);
238  }
239 
240  std::vector<T> input = armnnUtils::QuantizedVector<T>(
241  {
242  1, 2, 3,
243  11, 12, 13,
244  21, 22, 23,
245  31, 32, 33,
246  41, 42, 43,
247  51, 52, 53
248  },
249  qScale, qOffset);
250 
251  std::vector<T> outputExpected = armnnUtils::QuantizedVector<T>(
252  {
253  1, 11, 21, 31, 41, 51,
254  2, 12, 22, 32, 42, 52,
255  3, 13, 23, 33, 43, 53
256  },
257  qScale, qOffset);
258 
259  return SimpleTransposeTestImpl<T>(workloadFactory, memoryManager, tensorHandleFactory,
260  descriptor, inputTensorInfo,
261  outputTensorInfo, input, outputExpected);
262 }
LayerTestResult< T, 4 > SimpleTransposeTest(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
+
LayerTestResult< T, 4 > TransposeValueSet2Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
+ + + + + +
void IgnoreUnused(Ts &&...)
+
virtual std::unique_ptr< IWorkload > CreateTranspose(const TransposeQueueDescriptor &descriptor, const WorkloadInfo &info) const
+ + + +
std::shared_ptr< IMemoryManager > IMemoryManagerSharedPtr
+
LayerTestResult< T, 4 > TransposeValueSet1Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
+
void SetQuantizationScale(float scale)
Definition: Tensor.cpp:464
+ +
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
+ +
LayerTestResult< T, 4 > TransposeValueSet3Test(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
+ +
A TransposeDescriptor for the TransposeLayer.
+
Contains information about inputs and outputs to a layer.
+ +
void SetQuantizationOffset(int32_t offset)
Definition: Tensor.cpp:480
+
LayerTestResult< T, 4 > SimpleTransposeTestImpl(armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, armnn::TransposeDescriptor descriptor, armnn::TensorInfo inputTensorInfo, armnn::TensorInfo outputTensorInfo, const std::vector< T > &inputData, const std::vector< T > &outputExpectedData)
+
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const =0
+
PermutationVector m_DimMappings
Indicates how to translate tensor elements from a given source into the target destination, when source and target potentially have different memory layouts e.g.
+
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)
+
+
+ + + + -- cgit v1.2.1