ArmNN
 20.02
RefLayerSupportTests.cpp File Reference
#include <layers/ConvertFp16ToFp32Layer.hpp>
#include <layers/ConvertFp32ToFp16Layer.hpp>
#include <test/TensorHelpers.hpp>
#include <backendsCommon/CpuTensorHandle.hpp>
#include <reference/RefWorkloadFactory.hpp>
#include <reference/RefLayerSupport.hpp>
#include <backendsCommon/test/LayerTests.hpp>
#include <backendsCommon/test/IsLayerSupportedTestImpl.hpp>
#include <boost/test/unit_test.hpp>
#include <boost/algorithm/string/trim.hpp>
#include <string>

Go to the source code of this file.

Functions

 BOOST_AUTO_TEST_CASE (IsLayerSupportedLayerTypeMatches)
 
 BOOST_AUTO_TEST_CASE (IsLayerSupportedReferenceAddition)
 
 BOOST_AUTO_TEST_CASE (IsLayerSupportedBFloat16Reference)
 
 BOOST_AUTO_TEST_CASE (IsLayerSupportedFloat16Reference)
 
 BOOST_AUTO_TEST_CASE (IsLayerSupportedFloat32Reference)
 
 BOOST_AUTO_TEST_CASE (IsLayerSupportedUint8Reference)
 
 BOOST_AUTO_TEST_CASE (IsLayerSupportedInt8Reference)
 
 BOOST_AUTO_TEST_CASE (IsLayerSupportedInt16Reference)
 
 BOOST_AUTO_TEST_CASE (IsConvertFp16ToFp32SupportedReference)
 
 BOOST_AUTO_TEST_CASE (IsConvertFp16ToFp32SupportedFp32InputReference)
 
 BOOST_AUTO_TEST_CASE (IsConvertFp16ToFp32SupportedFp16OutputReference)
 
 BOOST_AUTO_TEST_CASE (IsConvertFp32ToFp16SupportedReference)
 
 BOOST_AUTO_TEST_CASE (IsConvertFp32ToFp16SupportedFp16InputReference)
 
 BOOST_AUTO_TEST_CASE (IsConvertFp32ToFp16SupportedFp32OutputReference)
 
 BOOST_AUTO_TEST_CASE (IsLayerSupportedMeanDimensionsReference)
 
 BOOST_AUTO_TEST_CASE (IsLayerNotSupportedMeanDimensionsReference)
 

Function Documentation

◆ BOOST_AUTO_TEST_CASE() [1/16]

BOOST_AUTO_TEST_CASE ( IsLayerSupportedLayerTypeMatches  )

Definition at line 33 of file RefLayerSupportTests.cpp.

34 {
35  LayerTypeMatchesTest();
36 }

◆ BOOST_AUTO_TEST_CASE() [2/16]

BOOST_AUTO_TEST_CASE ( IsLayerSupportedReferenceAddition  )

Definition at line 37 of file RefLayerSupportTests.cpp.

References BOOST_CHECK(), armnn::Float32, and RefLayerSupport::IsAdditionSupported().

38 {
39  armnn::TensorShape shape0 = {1,1,3,4};
40  armnn::TensorShape shape1 = {4};
41  armnn::TensorShape outShape = {1,1,3,4};
45 
46  armnn::RefLayerSupport supportChecker;
47  std::string reasonNotSupported;
48  BOOST_CHECK(supportChecker.IsAdditionSupported(in0, in1, out, reasonNotSupported));
49 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
bool IsAdditionSupported(const TensorInfo &input0, const TensorInfo &input1, const TensorInfo &output, Optional< std::string &> reasonIfUnsupported=EmptyOptional()) const override

◆ BOOST_AUTO_TEST_CASE() [3/16]

BOOST_AUTO_TEST_CASE ( IsLayerSupportedBFloat16Reference  )

Definition at line 51 of file RefLayerSupportTests.cpp.

52 {
54  IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::BFloat16>(&factory);
55 }

◆ BOOST_AUTO_TEST_CASE() [4/16]

BOOST_AUTO_TEST_CASE ( IsLayerSupportedFloat16Reference  )

Definition at line 57 of file RefLayerSupportTests.cpp.

58 {
60  IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float16>(&factory);
61 }

◆ BOOST_AUTO_TEST_CASE() [5/16]

BOOST_AUTO_TEST_CASE ( IsLayerSupportedFloat32Reference  )

Definition at line 63 of file RefLayerSupportTests.cpp.

64 {
66  IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float32>(&factory);
67 }

◆ BOOST_AUTO_TEST_CASE() [6/16]

BOOST_AUTO_TEST_CASE ( IsLayerSupportedUint8Reference  )

Definition at line 69 of file RefLayerSupportTests.cpp.

70 {
72  IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::QAsymmU8>(&factory);
73 }

◆ BOOST_AUTO_TEST_CASE() [7/16]

BOOST_AUTO_TEST_CASE ( IsLayerSupportedInt8Reference  )

Definition at line 75 of file RefLayerSupportTests.cpp.

76 {
78  IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::QSymmS8>(&factory);
79 }

◆ BOOST_AUTO_TEST_CASE() [8/16]

BOOST_AUTO_TEST_CASE ( IsLayerSupportedInt16Reference  )

Definition at line 81 of file RefLayerSupportTests.cpp.

82 {
84  IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::QSymmS16>(&factory);
85 }

◆ BOOST_AUTO_TEST_CASE() [9/16]

BOOST_AUTO_TEST_CASE ( IsConvertFp16ToFp32SupportedReference  )

Definition at line 87 of file RefLayerSupportTests.cpp.

References BOOST_CHECK(), armnn::Float16, and armnn::Float32.

88 {
89  std::string reasonIfUnsupported;
90 
91  bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
93 
94  BOOST_CHECK(result);
95 }
This layer converts data type Float 16 to Float 32.
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [10/16]

BOOST_AUTO_TEST_CASE ( IsConvertFp16ToFp32SupportedFp32InputReference  )

Definition at line 97 of file RefLayerSupportTests.cpp.

References BOOST_CHECK(), and armnn::Float32.

98 {
99  std::string reasonIfUnsupported;
100 
101  bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
102  armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
103 
104  BOOST_CHECK(!result);
105  BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type input");
106 }
This layer converts data type Float 16 to Float 32.
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [11/16]

BOOST_AUTO_TEST_CASE ( IsConvertFp16ToFp32SupportedFp16OutputReference  )

Definition at line 108 of file RefLayerSupportTests.cpp.

References BOOST_CHECK(), and armnn::Float16.

109 {
110  std::string reasonIfUnsupported;
111 
112  bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
113  armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported);
114 
115  BOOST_CHECK(!result);
116  BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type output");
117 }
This layer converts data type Float 16 to Float 32.
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [12/16]

BOOST_AUTO_TEST_CASE ( IsConvertFp32ToFp16SupportedReference  )

Definition at line 119 of file RefLayerSupportTests.cpp.

References BOOST_CHECK(), armnn::Float16, and armnn::Float32.

120 {
121  std::string reasonIfUnsupported;
122 
123  bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
124  armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported);
125 
126  BOOST_CHECK(result);
127 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
This layer converts data type Float 32 to Float 16.

◆ BOOST_AUTO_TEST_CASE() [13/16]

BOOST_AUTO_TEST_CASE ( IsConvertFp32ToFp16SupportedFp16InputReference  )

Definition at line 129 of file RefLayerSupportTests.cpp.

References BOOST_CHECK(), and armnn::Float16.

130 {
131  std::string reasonIfUnsupported;
132 
133  bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
134  armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported);
135 
136  BOOST_CHECK(!result);
137  BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type input");
138 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
This layer converts data type Float 32 to Float 16.

◆ BOOST_AUTO_TEST_CASE() [14/16]

BOOST_AUTO_TEST_CASE ( IsConvertFp32ToFp16SupportedFp32OutputReference  )

Definition at line 140 of file RefLayerSupportTests.cpp.

References BOOST_CHECK(), and armnn::Float32.

141 {
142  std::string reasonIfUnsupported;
143 
144  bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
145  armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
146 
147  BOOST_CHECK(!result);
148  BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type output");
149 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)
This layer converts data type Float 32 to Float 16.

◆ BOOST_AUTO_TEST_CASE() [15/16]

BOOST_AUTO_TEST_CASE ( IsLayerSupportedMeanDimensionsReference  )

Definition at line 151 of file RefLayerSupportTests.cpp.

References BOOST_CHECK(), and armnn::Float32.

152 {
153  std::string reasonIfUnsupported;
154 
155  bool result = IsMeanLayerSupportedTests<armnn::RefWorkloadFactory,
156  armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
157 
158  BOOST_CHECK(result);
159 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)

◆ BOOST_AUTO_TEST_CASE() [16/16]

BOOST_AUTO_TEST_CASE ( IsLayerNotSupportedMeanDimensionsReference  )

Definition at line 161 of file RefLayerSupportTests.cpp.

References BOOST_AUTO_TEST_SUITE_END(), BOOST_CHECK(), and armnn::Float32.

162 {
163  std::string reasonIfUnsupported;
164 
165  bool result = IsMeanLayerNotSupportedTests<armnn::RefWorkloadFactory,
166  armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
167 
168  BOOST_CHECK(!result);
169 
170  boost::algorithm::trim(reasonIfUnsupported);
171  BOOST_CHECK_EQUAL(reasonIfUnsupported,
172  "Reference Mean: Expected 4 dimensions but got 2 dimensions instead, for the 'output' tensor.");
173 }
BOOST_CHECK(profilingService.GetCurrentState()==ProfilingState::WaitingForAck)