IVGCVSW-1946: Remove armnn/src from the include paths
[platform/upstream/armnn.git] / src / backends / reference / test / RefLayerSupportTests.cpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5
6 #include <layers/ConvertFp16ToFp32Layer.hpp>
7 #include <layers/ConvertFp32ToFp16Layer.hpp>
8 #include <test/TensorHelpers.hpp>
9
10 #include <backendsCommon/CpuTensorHandle.hpp>
11 #include <reference/RefWorkloadFactory.hpp>
12 #include <backendsCommon/test/LayerTests.hpp>
13 #include <backendsCommon/test/IsLayerSupportedTestImpl.hpp>
14
15 #include <boost/test/unit_test.hpp>
16
17 #include <string>
18
19 namespace
20 {
21
22 bool LayerTypeMatchesTest()
23 {
24     return LayerTypeMatchesTestImpl<armnn::LayerType::FirstLayer>(Tag<armnn::LayerType::FirstLayer>());
25 };
26
27 } // anonymous namespace
28
29 BOOST_AUTO_TEST_SUITE(RefLayerSupported)
30
31 BOOST_AUTO_TEST_CASE(IsLayerSupportedLayerTypeMatches)
32 {
33     LayerTypeMatchesTest();
34 }
35
36 BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat16Reference)
37 {
38     armnn::RefWorkloadFactory factory;
39     IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float16>(&factory);
40 }
41
42 BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat32Reference)
43 {
44     armnn::RefWorkloadFactory factory;
45     IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float32>(&factory);
46 }
47
48 BOOST_AUTO_TEST_CASE(IsLayerSupportedUint8Reference)
49 {
50     armnn::RefWorkloadFactory factory;
51     IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::QuantisedAsymm8>(&factory);
52 }
53
54 BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedReference)
55 {
56     std::string reasonIfUnsupported;
57
58     bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
59       armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported);
60
61     BOOST_CHECK(result);
62 }
63
64 BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedFp32InputReference)
65 {
66     std::string reasonIfUnsupported;
67
68     bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
69       armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
70
71     BOOST_CHECK(!result);
72     BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type input");
73 }
74
75 BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedFp16OutputReference)
76 {
77     std::string reasonIfUnsupported;
78
79     bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer,
80       armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported);
81
82     BOOST_CHECK(!result);
83     BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type output");
84 }
85
86 BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedReference)
87 {
88     std::string reasonIfUnsupported;
89
90     bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
91       armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported);
92
93     BOOST_CHECK(result);
94 }
95
96 BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedFp16InputReference)
97 {
98     std::string reasonIfUnsupported;
99
100     bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
101       armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported);
102
103     BOOST_CHECK(!result);
104     BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type input");
105 }
106
107 BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedFp32OutputReference)
108 {
109     std::string reasonIfUnsupported;
110
111     bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer,
112       armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported);
113
114     BOOST_CHECK(!result);
115     BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type output");
116 }
117
118 BOOST_AUTO_TEST_SUITE_END()