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/_common_test_utils_8hpp.xhtml | 500 ++++++++++++++++++++++++++++++++++++ 1 file changed, 500 insertions(+) create mode 100644 21.11/_common_test_utils_8hpp.xhtml (limited to '21.11/_common_test_utils_8hpp.xhtml') diff --git a/21.11/_common_test_utils_8hpp.xhtml b/21.11/_common_test_utils_8hpp.xhtml new file mode 100644 index 0000000000..27cfb102e5 --- /dev/null +++ b/21.11/_common_test_utils_8hpp.xhtml @@ -0,0 +1,500 @@ + + + + + + + + + + + + + +ArmNN: src/backends/backendsCommon/test/CommonTestUtils.hpp File Reference + + + + + + + + + + + + + + + + +
+
+ + + + ArmNN + + + +
+
+  21.11 +
+
+
+ + + + + + + +
+
+ +
+
+
+ +
+ +
+
+ + +
+ +
+ +
+ +
+
CommonTestUtils.hpp File Reference
+
+
+
#include <Graph.hpp>
+#include <SubgraphView.hpp>
+#include <SubgraphViewSelector.hpp>
+#include <ResolveType.hpp>
+#include <armnn/BackendRegistry.hpp>
+#include <armnn/Types.hpp>
+#include <backendsCommon/TensorHandle.hpp>
+#include <test/TestUtils.hpp>
+#include <algorithm>
+#include <random>
+#include <vector>
+
+

Go to the source code of this file.

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

+Functions

template<typename CollectionType >
bool AreEqual (const CollectionType &lhs, const CollectionType &rhs)
 
template<typename CollectionType >
bool Contains (const CollectionType &collection, const typename CollectionType::value_type &item)
 
template<typename MapType >
bool Contains (const MapType &map, const typename MapType::key_type &key)
 
template<armnn::DataType ArmnnType, typename T = armnn::ResolveType<ArmnnType>>
bool Compare (T a, T b, float tolerance=0.000001f)
 
template<typename ConvolutionLayer >
void SetWeightAndBias (ConvolutionLayer *layer, const armnn::TensorInfo &weightInfo, const armnn::TensorInfo &biasInfo)
 
armnn::SubgraphView::InputSlots CreateInputsFrom (const std::vector< armnn::Layer *> &layers)
 
armnn::SubgraphView::OutputSlots CreateOutputsFrom (const std::vector< armnn::Layer *> &layers)
 
armnn::SubgraphView::SubgraphViewPtr CreateSubgraphViewFrom (armnn::SubgraphView::InputSlots &&inputs, armnn::SubgraphView::OutputSlots &&outputs, armnn::SubgraphView::Layers &&layers)
 
armnn::IBackendInternalUniquePtr CreateBackendObject (const armnn::BackendId &backendId)
 
armnn::TensorShape MakeTensorShape (unsigned int batches, unsigned int channels, unsigned int height, unsigned int width, armnn::DataLayout layout)
 
+

Function Documentation

+ +

◆ AreEqual()

+ +
+
+ + + + + + + + + + + + + + + + + + +
bool AreEqual (const CollectionType & lhs,
const CollectionType & rhs 
)
+
+ +

Definition at line 28 of file CommonTestUtils.hpp.

+
29 {
30  if (lhs.size() != rhs.size())
31  {
32  return false;
33  }
34 
35  auto lhs_it = std::find_if(lhs.begin(), lhs.end(), [&rhs](auto& item)
36  {
37  return std::find(rhs.begin(), rhs.end(), item) == rhs.end();
38  });
39 
40  return lhs_it == lhs.end();
41 }
+
+
+ +

◆ Compare()

+ +
+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + +
bool Compare (a,
b,
float tolerance = 0.000001f 
)
+
+inline
+
+ +

Definition at line 59 of file CommonTestUtils.hpp.

+ +

References armnn::Boolean.

+
60 {
61  if (ArmnnType == armnn::DataType::Boolean)
62  {
63  // NOTE: Boolean is represented as uint8_t (with zero equals
64  // false and everything else equals true), therefore values
65  // need to be casted to bool before comparing them
66  return static_cast<bool>(a) == static_cast<bool>(b);
67  }
68 
69  // NOTE: All other types can be cast to float and compared with
70  // a certain level of tolerance
71  return std::fabs(static_cast<float>(a) - static_cast<float>(b)) <= tolerance;
72 }
+
+
+
+ +

◆ Contains() [1/2]

+ +
+
+ + + + + + + + + + + + + + + + + + +
bool Contains (const CollectionType & collection,
const typename CollectionType::value_type & item 
)
+
+ +

Definition at line 45 of file CommonTestUtils.hpp.

+
46 {
47  return std::find(collection.begin(), collection.end(), item) != collection.end();
48 }
+
+
+ +

◆ Contains() [2/2]

+ +
+
+ + + + + + + + + + + + + + + + + + +
bool Contains (const MapType & map,
const typename MapType::key_type & key 
)
+
+ +

Definition at line 52 of file CommonTestUtils.hpp.

+
53 {
54  return map.find(key) != map.end();
55 }
+
+
+ +

◆ CreateBackendObject()

+ +
+
+ + + + + + + + +
armnn::IBackendInternalUniquePtr CreateBackendObject (const armnn::BackendIdbackendId)
+
+ +

Definition at line 45 of file CommonTestUtils.cpp.

+ +

References armnn::BackendRegistryInstance().

+ +

Referenced by SetWeightAndBias(), and TEST_SUITE().

+
46 {
47  auto& backendRegistry = BackendRegistryInstance();
48  auto backendFactory = backendRegistry.GetFactory(backendId);
49  auto backendObjPtr = backendFactory();
50 
51  return backendObjPtr;
52 }
BackendRegistry & BackendRegistryInstance()
+
+
+
+ +

◆ CreateInputsFrom()

+ +
+
+ + + + + + + + +
armnn::SubgraphView::InputSlots CreateInputsFrom (const std::vector< armnn::Layer *> & layers)
+
+ +

Definition at line 12 of file CommonTestUtils.cpp.

+ +

Referenced by armnn::FuseLayerWithoutParameters(), armnn::FuseLayerWithParameters(), armnn::ReplaceLayers(), armnn::ReportUntouchedLayers(), SetWeightAndBias(), and TEST_SUITE().

+
13 {
15  for (auto&& layer : layers)
16  {
17  for (auto&& it = layer->BeginInputSlots(); it != layer->EndInputSlots(); ++it)
18  {
19  result.push_back(&(*it));
20  }
21  }
22  return result;
23 }
std::vector< InputSlot * > InputSlots
+
+
+
+ +

◆ CreateOutputsFrom()

+ +
+
+ + + + + + + + +
armnn::SubgraphView::OutputSlots CreateOutputsFrom (const std::vector< armnn::Layer *> & layers)
+
+ +

Definition at line 25 of file CommonTestUtils.cpp.

+ +

Referenced by armnn::FuseLayerWithoutParameters(), armnn::FuseLayerWithParameters(), armnn::ReplaceLayers(), armnn::ReportUntouchedLayers(), SetWeightAndBias(), and TEST_SUITE().

+
26 {
28  for (auto && layer : layers)
29  {
30  for (auto&& it = layer->BeginOutputSlots(); it != layer->EndOutputSlots(); ++it)
31  {
32  result.push_back(&(*it));
33  }
34  }
35  return result;
36 }
std::vector< OutputSlot * > OutputSlots
+
+
+
+ +

◆ CreateSubgraphViewFrom()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
armnn::SubgraphView::SubgraphViewPtr CreateSubgraphViewFrom (armnn::SubgraphView::InputSlots && inputs,
armnn::SubgraphView::OutputSlots && outputs,
armnn::SubgraphView::Layers && layers 
)
+
+ +

Definition at line 38 of file CommonTestUtils.cpp.

+ +

Referenced by SetWeightAndBias(), and TEST_SUITE().

+
41 {
42  return std::make_unique<SubgraphView>(std::move(inputs), std::move(outputs), std::move(layers));
43 }
+
+
+ +

◆ MakeTensorShape()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
armnn::TensorShape MakeTensorShape (unsigned int batches,
unsigned int channels,
unsigned int height,
unsigned int width,
armnn::DataLayout layout 
)
+
+ +

Definition at line 54 of file CommonTestUtils.cpp.

+ +

References armnn::GetDataLayoutName(), armnn::NCHW, and armnn::NHWC.

+ +

Referenced by SetWeightAndBias(), and TransposeConvolution2dEndToEnd().

+
59 {
60  using namespace armnn;
61  switch (layout)
62  {
63  case DataLayout::NCHW:
64  return TensorShape{ batches, channels, height, width };
65  case DataLayout::NHWC:
66  return TensorShape{ batches, height, width, channels };
67  default:
68  throw InvalidArgumentException(std::string("Unsupported data layout: ") + GetDataLayoutName(layout));
69  }
70 }
constexpr const char * GetDataLayoutName(DataLayout dataLayout)
Definition: TypesUtils.hpp:222
+
Copyright (c) 2021 ARM Limited and Contributors.
+ + + + +
+
+
+ +

◆ SetWeightAndBias()

+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + +
void SetWeightAndBias (ConvolutionLayer * layer,
const armnn::TensorInfoweightInfo,
const armnn::TensorInfobiasInfo 
)
+
+ +

Definition at line 75 of file CommonTestUtils.hpp.

+ +

References CreateBackendObject(), CreateInputsFrom(), CreateOutputsFrom(), CreateSubgraphViewFrom(), and MakeTensorShape().

+
76 {
77  layer->m_Weight = std::make_unique<armnn::ScopedTensorHandle>(weightInfo);
78  layer->m_Bias = std::make_unique<armnn::ScopedTensorHandle>(biasInfo);
79 
80  layer->m_Weight->Allocate();
81  layer->m_Bias->Allocate();
82 }
+
+
+
+
+ + + + -- cgit v1.2.1