From 9aed8fb43441228343b925b42464a55042c47ca0 Mon Sep 17 00:00:00 2001 From: Nikhil Raj Date: Wed, 17 Nov 2021 13:16:45 +0000 Subject: IVGCVSW-6040 Update 21.11 Doxygen Documents Signed-off-by: Nikhil Raj Change-Id: Ia36ec98c4bebc27a69103911ea3409cd7db587a5 --- 21.11/_permute_test_impl_8hpp.xhtml | 394 ++++++++++++++++++++++++++++++++++++ 1 file changed, 394 insertions(+) create mode 100644 21.11/_permute_test_impl_8hpp.xhtml (limited to '21.11/_permute_test_impl_8hpp.xhtml') diff --git a/21.11/_permute_test_impl_8hpp.xhtml b/21.11/_permute_test_impl_8hpp.xhtml new file mode 100644 index 0000000000..1cc0b88f79 --- /dev/null +++ b/21.11/_permute_test_impl_8hpp.xhtml @@ -0,0 +1,394 @@ + + + + + + + + + + + + + +ArmNN: src/backends/backendsCommon/test/layerTests/PermuteTestImpl.hpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  21.11 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
PermuteTestImpl.hpp File Reference
+
+
+ +

Go to the source code of this file.

+ + + + + + + + + + + + + + + + + +

+Functions

template<typename T >
LayerTestResult< T, 4 > SimplePermuteTestImpl (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory, armnn::PermuteDescriptor descriptor, armnn::TensorInfo inputTensorInfo, armnn::TensorInfo outputTensorInfo, const std::vector< T > &inputData, const std::vector< T > &outputExpectedData)
 
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 4 > SimplePermuteTest (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 4 > PermuteValueSet1Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 4 > PermuteValueSet2Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
LayerTestResult< T, 4 > PermuteValueSet3Test (armnn::IWorkloadFactory &workloadFactory, const armnn::IBackendInternal::IMemoryManagerSharedPtr &memoryManager, const armnn::ITensorHandleFactory &tensorHandleFactory)
 
+

Function Documentation

+ +

◆ PermuteValueSet1Test()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
LayerTestResult<T, 4> PermuteValueSet1Test (armnn::IWorkloadFactoryworkloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtrmemoryManager,
const armnn::ITensorHandleFactorytensorHandleFactory 
)
+
+ +

Definition at line 110 of file PermuteTestImpl.hpp.

+ +

References PermuteDescriptor::m_DimMappings, TensorInfo::SetQuantizationOffset(), and TensorInfo::SetQuantizationScale().

+
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::PermuteDescriptor descriptor;
122  descriptor.m_DimMappings = {0U, 2U, 3U, 1U};
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 SimplePermuteTestImpl<T>(workloadFactory, memoryManager, tensorHandleFactory,
156  descriptor, inputTensorInfo,
157  outputTensorInfo, input, outputExpected);
158 }
+
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 SetQuantizationScale(float scale)
Definition: Tensor.cpp:475
+
void SetQuantizationOffset(int32_t offset)
Definition: Tensor.cpp:491
+
A PermuteDescriptor for the PermuteLayer.
+
+
+
+ +

◆ PermuteValueSet2Test()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
LayerTestResult<T, 4> PermuteValueSet2Test (armnn::IWorkloadFactoryworkloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtrmemoryManager,
const armnn::ITensorHandleFactorytensorHandleFactory 
)
+
+ +

Definition at line 161 of file PermuteTestImpl.hpp.

+ +

References PermuteDescriptor::m_DimMappings, TensorInfo::SetQuantizationOffset(), and TensorInfo::SetQuantizationScale().

+
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::PermuteDescriptor descriptor;
173  descriptor.m_DimMappings = {0U, 3U, 1U, 2U};
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 SimplePermuteTestImpl<T>(workloadFactory, memoryManager, tensorHandleFactory,
207  descriptor, inputTensorInfo,
208  outputTensorInfo, input, outputExpected);
209 }
+
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 SetQuantizationScale(float scale)
Definition: Tensor.cpp:475
+
void SetQuantizationOffset(int32_t offset)
Definition: Tensor.cpp:491
+
A PermuteDescriptor for the PermuteLayer.
+
+
+
+ +

◆ PermuteValueSet3Test()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
LayerTestResult<T, 4> PermuteValueSet3Test (armnn::IWorkloadFactoryworkloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtrmemoryManager,
const armnn::ITensorHandleFactorytensorHandleFactory 
)
+
+ +

Definition at line 212 of file PermuteTestImpl.hpp.

+ +

References PermuteDescriptor::m_DimMappings, TensorInfo::SetQuantizationOffset(), and TensorInfo::SetQuantizationScale().

+
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::PermuteDescriptor descriptor;
224  descriptor.m_DimMappings = {0U, 2U, 3U, 1U};
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 SimplePermuteTestImpl<T>(workloadFactory, memoryManager, tensorHandleFactory,
260  descriptor, inputTensorInfo,
261  outputTensorInfo, input, outputExpected);
262 }
+
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 SetQuantizationScale(float scale)
Definition: Tensor.cpp:475
+
void SetQuantizationOffset(int32_t offset)
Definition: Tensor.cpp:491
+
A PermuteDescriptor for the PermuteLayer.
+
+
+
+ +

◆ SimplePermuteTest()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
LayerTestResult<T, 4> SimplePermuteTest (armnn::IWorkloadFactoryworkloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtrmemoryManager,
const armnn::ITensorHandleFactorytensorHandleFactory 
)
+
+ +

Definition at line 60 of file PermuteTestImpl.hpp.

+ +

References PermuteDescriptor::m_DimMappings, TensorInfo::SetQuantizationOffset(), and TensorInfo::SetQuantizationScale().

+
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::PermuteDescriptor descriptor;
72  descriptor.m_DimMappings = {0U, 3U, 1U, 2U};
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 SimplePermuteTestImpl<T>(workloadFactory, memoryManager, tensorHandleFactory,
105  descriptor, inputTensorInfo,
106  outputTensorInfo, input, outputExpected);
107 }
+
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 SetQuantizationScale(float scale)
Definition: Tensor.cpp:475
+
void SetQuantizationOffset(int32_t offset)
Definition: Tensor.cpp:491
+
A PermuteDescriptor for the PermuteLayer.
+
+
+
+ +

◆ SimplePermuteTestImpl()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LayerTestResult<T, 4> SimplePermuteTestImpl (armnn::IWorkloadFactoryworkloadFactory,
const armnn::IBackendInternal::IMemoryManagerSharedPtrmemoryManager,
const armnn::ITensorHandleFactorytensorHandleFactory,
armnn::PermuteDescriptor descriptor,
armnn::TensorInfo inputTensorInfo,
armnn::TensorInfo outputTensorInfo,
const std::vector< T > & inputData,
const std::vector< T > & outputExpectedData 
)
+
+ +

Definition at line 19 of file PermuteTestImpl.hpp.

+ +

References CopyDataFromITensorHandle(), CopyDataToITensorHandle(), IWorkloadFactory::CreatePermute(), ITensorHandleFactory::CreateTensorHandle(), TensorInfo::GetNumElements(), TensorInfo::GetShape(), armnn::IgnoreUnused(), and QueueDescriptorWithParameters< LayerDescriptor >::m_Parameters.

+
28 {
29  IgnoreUnused(memoryManager);
30 
31  std::vector<T> actualOutput(outputTensorInfo.GetNumElements());
32 
33  std::unique_ptr<armnn::ITensorHandle> inputHandle = tensorHandleFactory.CreateTensorHandle(inputTensorInfo);
34  std::unique_ptr<armnn::ITensorHandle> outputHandle = tensorHandleFactory.CreateTensorHandle(outputTensorInfo);
35 
37  data.m_Parameters = descriptor;
39  AddInputToWorkload(data, info, inputTensorInfo, inputHandle.get());
40  AddOutputToWorkload(data, info, outputTensorInfo, outputHandle.get());
41 
42  std::unique_ptr<armnn::IWorkload> workload = workloadFactory.CreatePermute(data, info);
43 
44  inputHandle->Allocate();
45  outputHandle->Allocate();
46 
47  CopyDataToITensorHandle(inputHandle.get(), inputData.data());
48 
49  workload->Execute();
50 
51  CopyDataFromITensorHandle(actualOutput.data(), outputHandle.get());
52 
53  return LayerTestResult<T, 4>(actualOutput,
54  outputExpectedData,
55  outputHandle->GetShape(),
56  outputTensorInfo.GetShape());
57 }
+
const TensorShape & GetShape() const
Definition: Tensor.hpp:191
+
void IgnoreUnused(Ts &&...)
+ +
void CopyDataFromITensorHandle(void *memory, const armnn::ITensorHandle *tensorHandle)
+
virtual std::unique_ptr< IWorkload > CreatePermute(const PermuteQueueDescriptor &descriptor, const WorkloadInfo &info) const
+ +
Contains information about TensorInfos of a layer.
+ +
virtual std::unique_ptr< ITensorHandle > CreateTensorHandle(const TensorInfo &tensorInfo) const =0
+
unsigned int GetNumElements() const
Definition: Tensor.hpp:196
+
void CopyDataToITensorHandle(armnn::ITensorHandle *tensorHandle, const void *memory)
+
+
+
+
+
+ + + + -- cgit v1.2.1