ArmNN
 21.05
CommonTestUtils.cpp File Reference

Go to the source code of this file.

Functions

SubgraphView::InputSlots CreateInputsFrom (const std::vector< Layer *> &layers)
 
SubgraphView::OutputSlots CreateOutputsFrom (const std::vector< Layer *> &layers)
 
SubgraphView::SubgraphViewPtr CreateSubgraphViewFrom (SubgraphView::InputSlots &&inputs, SubgraphView::OutputSlots &&outputs, 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

◆ CreateBackendObject()

armnn::IBackendInternalUniquePtr CreateBackendObject ( const armnn::BackendId backendId)

Definition at line 45 of file CommonTestUtils.cpp.

References armnn::BackendRegistryInstance().

Referenced by BOOST_AUTO_TEST_CASE(), and SetWeightAndBias().

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

◆ CreateInputsFrom()

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

Definition at line 12 of file CommonTestUtils.cpp.

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

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()

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

Definition at line 25 of file CommonTestUtils.cpp.

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

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()

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

Definition at line 38 of file CommonTestUtils.cpp.

Referenced by BOOST_AUTO_TEST_CASE(), and SetWeightAndBias().

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:214
Copyright (c) 2021 ARM Limited and Contributors.