2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
6 #include <layers/ConvertFp16ToFp32Layer.hpp>
7 #include <layers/ConvertFp32ToFp16Layer.hpp>
8 #include <test/TensorHelpers.hpp>
10 #include <backendsCommon/CpuTensorHandle.hpp>
11 #include <reference/RefWorkloadFactory.hpp>
12 #include <backendsCommon/test/LayerTests.hpp>
13 #include <backendsCommon/test/IsLayerSupportedTestImpl.hpp>
15 #include <boost/test/unit_test.hpp>
22 bool LayerTypeMatchesTest()
24 return LayerTypeMatchesTestImpl<armnn::LayerType::FirstLayer>(Tag<armnn::LayerType::FirstLayer>());
27 } // anonymous namespace
29 BOOST_AUTO_TEST_SUITE(RefLayerSupported)
31 BOOST_AUTO_TEST_CASE(IsLayerSupportedLayerTypeMatches)
33 LayerTypeMatchesTest();
36 BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat16Reference)
38 armnn::RefWorkloadFactory factory;
39 IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float16>(&factory);
42 BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat32Reference)
44 armnn::RefWorkloadFactory factory;
45 IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float32>(&factory);
48 BOOST_AUTO_TEST_CASE(IsLayerSupportedUint8Reference)
50 armnn::RefWorkloadFactory factory;
51 IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::QuantisedAsymm8>(&factory);
54 BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedReference)
56 std::string reasonIfUnsupported;
58 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
59 armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported);
64 BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedFp32InputReference)
66 std::string reasonIfUnsupported;
68 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
69 armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
72 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type input");
75 BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedFp16OutputReference)
77 std::string reasonIfUnsupported;
79 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
80 armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported);
83 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type output");
86 BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedReference)
88 std::string reasonIfUnsupported;
90 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
91 armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported);
96 BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedFp16InputReference)
98 std::string reasonIfUnsupported;
100 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
101 armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported);
103 BOOST_CHECK(!result);
104 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type input");
107 BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedFp32OutputReference)
109 std::string reasonIfUnsupported;
111 bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
112 armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
114 BOOST_CHECK(!result);
115 BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type output");
118 BOOST_AUTO_TEST_SUITE_END()