ArmNN
 22.05.01
TestLayerVisitor Class Reference

#include <TestLayerVisitor.hpp>

Inheritance diagram for TestLayerVisitor:
StrategyBase< NoThrowStrategy > IStrategy LstmVisitor TestBatchNormalizationLayerVisitor TestConstantLayerVisitor TestConvolution2dLayerVisitor TestDepthwiseConvolution2dLayerVisitor TestFullyConnectedLayerVistor TestInputLayerVisitor TestOutputLayerVisitor TestQuantizedLstmLayerVisitor TestActivationLayerVisitor TestAdditionLayerVisitor TestArgMinMaxLayerVisitor TestBatchToSpaceNdLayerVisitor TestComparisonLayerVisitor TestConcatLayerVisitor TestDepthToSpaceLayerVisitor TestDequantizeLayerVisitor TestDivisionLayerVisitor TestElementwiseUnaryLayerVisitor TestFillLayerVisitor TestFloorLayerVisitor TestGatherLayerVisitor TestInstanceNormalizationLayerVisitor TestL2NormalizationLayerVisitor TestLogicalBinaryLayerVisitor TestLogSoftmaxLayerVisitor TestMaximumLayerVisitor TestMeanLayerVisitor TestMergeLayerVisitor TestMinimumLayerVisitor TestMultiplicationLayerVisitor TestNormalizationLayerVisitor TestPadLayerVisitor TestPermuteLayerVisitor TestPooling2dLayerVisitor TestPreluLayerVisitor TestQuantizeLayerVisitor TestRankLayerVisitor TestReduceLayerVisitor TestReshapeLayerVisitor TestResizeLayerVisitor TestSliceLayerVisitor TestSoftmaxLayerVisitor TestSpaceToBatchNdLayerVisitor TestSpaceToDepthLayerVisitor TestSplitterLayerVisitor TestStackLayerVisitor TestStandInLayerVisitor TestStridedSliceLayerVisitor TestSubtractionLayerVisitor TestSwitchLayerVisitor TestTransposeLayerVisitor

Public Member Functions

 TestLayerVisitor (const char *name)
 
- Public Member Functions inherited from StrategyBase< NoThrowStrategy >
virtual void ExecuteStrategy (const armnn::IConnectableLayer *layer, const armnn::BaseDescriptor &descriptor, const std::vector< armnn::ConstTensor > &constants, const char *name, const armnn::LayerBindingId id=0) override
 
- Public Member Functions inherited from IStrategy
virtual void FinishStrategy ()
 

Protected Member Functions

virtual ~TestLayerVisitor ()
 
void CheckLayerName (const char *name)
 
void CheckLayerPointer (const IConnectableLayer *layer)
 
void CheckConstTensors (const ConstTensor &expected, const ConstTensor &actual)
 
void CheckConstTensors (const ConstTensor &expected, const ConstTensorHandle &actual)
 
void CheckConstTensorPtrs (const std::string &name, const ConstTensor *expected, const ConstTensor *actual)
 
void CheckConstTensorPtrs (const std::string &name, const ConstTensor *expected, const std::shared_ptr< ConstTensorHandle > actual)
 
void CheckOptionalConstTensors (const Optional< ConstTensor > &expected, const Optional< ConstTensor > &actual)
 
- Protected Member Functions inherited from StrategyBase< NoThrowStrategy >
virtual ~StrategyBase ()
 
- Protected Member Functions inherited from IStrategy
 IStrategy ()
 
virtual ~IStrategy ()
 

Additional Inherited Members

- Protected Attributes inherited from StrategyBase< NoThrowStrategy >
NoThrowStrategy m_DefaultStrategy
 

Detailed Description

Definition at line 14 of file TestLayerVisitor.hpp.

Constructor & Destructor Documentation

◆ ~TestLayerVisitor()

◆ TestLayerVisitor()

TestLayerVisitor ( const char *  name)
inlineexplicit

Definition at line 41 of file TestLayerVisitor.hpp.

41  : m_LayerName(name)
42  {
43  if (name == nullptr)
44  {
45  m_LayerName = "";
46  }
47  }

Member Function Documentation

◆ CheckConstTensorPtrs() [1/2]

void CheckConstTensorPtrs ( const std::string &  name,
const ConstTensor expected,
const ConstTensor actual 
)
protected

Definition at line 90 of file TestLayerVisitor.cpp.

References TestLayerVisitor::CheckConstTensors().

Referenced by LstmVisitor::CheckInputParameters(), TestQuantizedLstmLayerVisitor::CheckInputParameters(), and TestLayerVisitor::~TestLayerVisitor().

93 {
94  if (expected == nullptr)
95  {
96  CHECK_MESSAGE(actual == nullptr, (name + " actual should have been a nullptr"));
97  }
98  else
99  {
100  CHECK_MESSAGE(actual != nullptr, (name + " actual should have been set"));
101  if (actual != nullptr)
102  {
103  CheckConstTensors(*expected, *actual);
104  }
105  }
106 }
void CheckConstTensors(const ConstTensor &expected, const ConstTensor &actual)

◆ CheckConstTensorPtrs() [2/2]

void CheckConstTensorPtrs ( const std::string &  name,
const ConstTensor expected,
const std::shared_ptr< ConstTensorHandle actual 
)
protected

Definition at line 72 of file TestLayerVisitor.cpp.

References TestLayerVisitor::CheckConstTensors().

75 {
76  if (expected == nullptr)
77  {
78  CHECK_MESSAGE(actual == nullptr, (name + " actual should have been a nullptr"));
79  }
80  else
81  {
82  CHECK_MESSAGE(actual != nullptr, (name + " actual should have been set"));
83  if (actual != nullptr)
84  {
85  CheckConstTensors(*expected, *actual);
86  }
87  }
88 }
void CheckConstTensors(const ConstTensor &expected, const ConstTensor &actual)

◆ CheckConstTensors() [1/2]

void CheckConstTensors ( const ConstTensor expected,
const ConstTensor actual 
)
protected

Definition at line 34 of file TestLayerVisitor.cpp.

References BaseTensor< MemoryType >::GetInfo(), BaseTensor< MemoryType >::GetMemoryArea(), BaseTensor< MemoryType >::GetNumBytes(), BaseTensor< MemoryType >::GetNumDimensions(), and BaseTensor< MemoryType >::GetNumElements().

Referenced by TestLayerVisitor::CheckConstTensorPtrs(), TestLayerVisitor::CheckOptionalConstTensors(), TestBatchNormalizationLayerVisitor::ExecuteStrategy(), TestConstantLayerVisitor::ExecuteStrategy(), and TestLayerVisitor::~TestLayerVisitor().

35 {
36  CHECK(expected.GetInfo() == actual.GetInfo());
37  CHECK(expected.GetNumDimensions() == actual.GetNumDimensions());
38  CHECK(expected.GetNumElements() == actual.GetNumElements());
39  CHECK(expected.GetNumBytes() == actual.GetNumBytes());
40  if (expected.GetNumBytes() == actual.GetNumBytes())
41  {
42  //check data is the same byte by byte
43  const unsigned char* expectedPtr = static_cast<const unsigned char*>(expected.GetMemoryArea());
44  const unsigned char* actualPtr = static_cast<const unsigned char*>(actual.GetMemoryArea());
45  for (unsigned int i = 0; i < expected.GetNumBytes(); i++)
46  {
47  CHECK(*(expectedPtr + i) == *(actualPtr + i));
48  }
49  }
50 }

◆ CheckConstTensors() [2/2]

void CheckConstTensors ( const ConstTensor expected,
const ConstTensorHandle actual 
)
protected

Definition at line 52 of file TestLayerVisitor.cpp.

References BaseTensor< MemoryType >::GetInfo(), BaseTensor< MemoryType >::GetMemoryArea(), BaseTensor< MemoryType >::GetNumBytes(), BaseTensor< MemoryType >::GetNumDimensions(), BaseTensor< MemoryType >::GetNumElements(), ConstTensorHandle::GetTensorInfo(), ConstTensorHandle::Map(), and ConstTensorHandle::Unmap().

53 {
54  auto& actualInfo = actual.GetTensorInfo();
55  CHECK(expected.GetInfo() == actualInfo);
56  CHECK(expected.GetNumDimensions() == actualInfo.GetNumDimensions());
57  CHECK(expected.GetNumElements() == actualInfo.GetNumElements());
58  CHECK(expected.GetNumBytes() == actualInfo.GetNumBytes());
59  if (expected.GetNumBytes() == actualInfo.GetNumBytes())
60  {
61  //check data is the same byte by byte
62  const unsigned char* expectedPtr = static_cast<const unsigned char*>(expected.GetMemoryArea());
63  const unsigned char* actualPtr = static_cast<const unsigned char*>(actual.Map(true));
64  for (unsigned int i = 0; i < expected.GetNumBytes(); i++)
65  {
66  CHECK(*(expectedPtr + i) == *(actualPtr + i));
67  }
68  actual.Unmap();
69  }
70 }

◆ CheckLayerName()

void CheckLayerName ( const char *  name)
protected

◆ CheckLayerPointer()

◆ CheckOptionalConstTensors()

void CheckOptionalConstTensors ( const Optional< ConstTensor > &  expected,
const Optional< ConstTensor > &  actual 
)
protected

Definition at line 108 of file TestLayerVisitor.cpp.

References TestLayerVisitor::CheckConstTensors(), OptionalBase::has_value(), and OptionalReferenceSwitch< std::is_reference< T >::value, T >::value().

Referenced by TestLayerVisitor::~TestLayerVisitor().

110 {
111  CHECK(expected.has_value() == actual.has_value());
112  if (expected.has_value() && actual.has_value())
113  {
114  CheckConstTensors(expected.value(), actual.value());
115  }
116 }
void CheckConstTensors(const ConstTensor &expected, const ConstTensor &actual)

The documentation for this class was generated from the following files: