2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // See LICENSE file in the project root for full license information.
5 #include <boost/test/unit_test.hpp>
7 #include "test/TensorHelpers.hpp"
8 #include "LayerTests.hpp"
10 #include "backends/CpuTensorHandle.hpp"
11 #include "backends/RefWorkloadFactory.hpp"
15 #include <backends/ClWorkloadFactory.hpp>
16 #include <backends/NeonWorkloadFactory.hpp>
18 #include "IsLayerSupportedTestImpl.hpp"
19 #include "ClContextControlFixture.hpp"
21 #include "layers/ConvertFp16ToFp32Layer.hpp"
22 #include "layers/ConvertFp32ToFp16Layer.hpp"
24 BOOST_AUTO_TEST_SUITE(IsLayerSupported)
26 BOOST_AUTO_TEST_CASE(IsLayerSupportedLayerTypeMatches)
28 LayerTypeMatchesTest();
31 BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat16Reference)
33 armnn::RefWorkloadFactory factory;
34 IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float16>(&factory);
37 BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat32Reference)
39 armnn::RefWorkloadFactory factory;
40 IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float32>(&factory);
43 BOOST_AUTO_TEST_CASE(IsLayerSupportedUint8Reference)
45 armnn::RefWorkloadFactory factory;
46 IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::QuantisedAsymm8>(&factory);
49 BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedReference)
51 std::string reasonIfUnsupported;
53 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
54 armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported);
59 BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedFp32InputReference)
61 std::string reasonIfUnsupported;
63 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
64 armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
67 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type input");
70 BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedFp16OutputReference)
72 std::string reasonIfUnsupported;
74 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
75 armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported);
78 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type output");
81 BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedReference)
83 std::string reasonIfUnsupported;
85 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
86 armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported);
91 BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedFp16InputReference)
93 std::string reasonIfUnsupported;
95 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
96 armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported);
99 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type input");
102 BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedFp32OutputReference)
104 std::string reasonIfUnsupported;
106 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
107 armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
109 BOOST_CHECK(!result);
110 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type output");
113 #ifdef ARMCOMPUTENEON_ENABLED
114 BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat16Neon)
116 armnn::NeonWorkloadFactory factory;
117 IsLayerSupportedTests<armnn::NeonWorkloadFactory, armnn::DataType::Float16>(&factory);
120 BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat32Neon)
122 armnn::NeonWorkloadFactory factory;
123 IsLayerSupportedTests<armnn::NeonWorkloadFactory, armnn::DataType::Float32>(&factory);
126 BOOST_AUTO_TEST_CASE(IsLayerSupportedUint8Neon)
128 armnn::NeonWorkloadFactory factory;
129 IsLayerSupportedTests<armnn::NeonWorkloadFactory, armnn::DataType::QuantisedAsymm8>(&factory);
132 BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedNeon)
134 std::string reasonIfUnsupported;
136 bool result = IsConvertLayerSupportedTests<armnn::NeonWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
137 armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported);
142 BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedNeon)
144 std::string reasonIfUnsupported;
146 bool result = IsConvertLayerSupportedTests<armnn::NeonWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
147 armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported);
151 #endif //#ifdef ARMCOMPUTENEON_ENABLED.
154 #ifdef ARMCOMPUTECL_ENABLED
156 BOOST_FIXTURE_TEST_CASE(IsLayerSupportedFloat16Cl, ClContextControlFixture)
158 armnn::ClWorkloadFactory factory;
159 IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::Float16>(&factory);
162 BOOST_FIXTURE_TEST_CASE(IsLayerSupportedFloat32Cl, ClContextControlFixture)
164 armnn::ClWorkloadFactory factory;
165 IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::Float32>(&factory);
168 BOOST_FIXTURE_TEST_CASE(IsLayerSupportedUint8Cl, ClContextControlFixture)
170 armnn::ClWorkloadFactory factory;
171 IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::QuantisedAsymm8>(&factory);
174 BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedCl, ClContextControlFixture)
176 std::string reasonIfUnsupported;
178 bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
179 armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported);
184 BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedFp32InputCl, ClContextControlFixture)
186 std::string reasonIfUnsupported;
188 bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
189 armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
191 BOOST_CHECK(!result);
192 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Input should be Float16");
195 BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedFp16OutputCl, ClContextControlFixture)
197 std::string reasonIfUnsupported;
199 bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
200 armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported);
202 BOOST_CHECK(!result);
203 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Output should be Float32");
206 BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedCl, ClContextControlFixture)
208 std::string reasonIfUnsupported;
210 bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
211 armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported);
216 BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedFp16InputCl, ClContextControlFixture)
218 std::string reasonIfUnsupported;
220 bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
221 armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported);
223 BOOST_CHECK(!result);
224 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Input should be Float32");
227 BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedFp32OutputCl, ClContextControlFixture)
229 std::string reasonIfUnsupported;
231 bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
232 armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
234 BOOST_CHECK(!result);
235 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Output should be Float16");
237 #endif //#ifdef ARMCOMPUTECL_ENABLED.
239 BOOST_AUTO_TEST_SUITE_END()