telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 4 | // |
| 5 | #include <boost/test/unit_test.hpp> |
| 6 | |
| 7 | #include "test/TensorHelpers.hpp" |
| 8 | #include "LayerTests.hpp" |
| 9 | |
David Beck | b4540be | 2018-09-24 13:18:27 +0100 | [diff] [blame] | 10 | #include <backends/CpuTensorHandle.hpp> |
| 11 | #include <backends/reference/RefWorkloadFactory.hpp> |
David Beck | 0dbe0ee | 2018-09-24 15:59:27 +0100 | [diff] [blame^] | 12 | #include <backends/neon/NeonWorkloadFactory.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 13 | |
| 14 | #include <string> |
| 15 | #include <iostream> |
| 16 | #include <backends/ClWorkloadFactory.hpp> |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 17 | |
| 18 | #include "IsLayerSupportedTestImpl.hpp" |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 19 | #include "ClContextControlFixture.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 20 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 21 | #include "layers/ConvertFp16ToFp32Layer.hpp" |
| 22 | #include "layers/ConvertFp32ToFp16Layer.hpp" |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 23 | |
| 24 | BOOST_AUTO_TEST_SUITE(IsLayerSupported) |
| 25 | |
| 26 | BOOST_AUTO_TEST_CASE(IsLayerSupportedLayerTypeMatches) |
| 27 | { |
| 28 | LayerTypeMatchesTest(); |
| 29 | } |
| 30 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 31 | BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat16Reference) |
| 32 | { |
| 33 | armnn::RefWorkloadFactory factory; |
| 34 | IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float16>(&factory); |
| 35 | } |
| 36 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 37 | BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat32Reference) |
| 38 | { |
| 39 | armnn::RefWorkloadFactory factory; |
| 40 | IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float32>(&factory); |
| 41 | } |
| 42 | |
| 43 | BOOST_AUTO_TEST_CASE(IsLayerSupportedUint8Reference) |
| 44 | { |
| 45 | armnn::RefWorkloadFactory factory; |
| 46 | IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::QuantisedAsymm8>(&factory); |
| 47 | } |
| 48 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 49 | BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedReference) |
| 50 | { |
| 51 | std::string reasonIfUnsupported; |
| 52 | |
| 53 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 54 | armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported); |
| 55 | |
| 56 | BOOST_CHECK(result); |
| 57 | } |
| 58 | |
| 59 | BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedFp32InputReference) |
| 60 | { |
| 61 | std::string reasonIfUnsupported; |
| 62 | |
| 63 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 64 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 65 | |
| 66 | BOOST_CHECK(!result); |
| 67 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type input"); |
| 68 | } |
| 69 | |
| 70 | BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedFp16OutputReference) |
| 71 | { |
| 72 | std::string reasonIfUnsupported; |
| 73 | |
| 74 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 75 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 76 | |
| 77 | BOOST_CHECK(!result); |
| 78 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type output"); |
| 79 | } |
| 80 | |
| 81 | BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedReference) |
| 82 | { |
| 83 | std::string reasonIfUnsupported; |
| 84 | |
| 85 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 86 | armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported); |
| 87 | |
| 88 | BOOST_CHECK(result); |
| 89 | } |
| 90 | |
| 91 | BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedFp16InputReference) |
| 92 | { |
| 93 | std::string reasonIfUnsupported; |
| 94 | |
| 95 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 96 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 97 | |
| 98 | BOOST_CHECK(!result); |
| 99 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type input"); |
| 100 | } |
| 101 | |
| 102 | BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedFp32OutputReference) |
| 103 | { |
| 104 | std::string reasonIfUnsupported; |
| 105 | |
| 106 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 107 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 108 | |
| 109 | BOOST_CHECK(!result); |
| 110 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type output"); |
| 111 | } |
| 112 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 113 | #ifdef ARMCOMPUTENEON_ENABLED |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 114 | BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat16Neon) |
| 115 | { |
| 116 | armnn::NeonWorkloadFactory factory; |
| 117 | IsLayerSupportedTests<armnn::NeonWorkloadFactory, armnn::DataType::Float16>(&factory); |
| 118 | } |
| 119 | |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 120 | BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat32Neon) |
| 121 | { |
| 122 | armnn::NeonWorkloadFactory factory; |
| 123 | IsLayerSupportedTests<armnn::NeonWorkloadFactory, armnn::DataType::Float32>(&factory); |
| 124 | } |
| 125 | |
| 126 | BOOST_AUTO_TEST_CASE(IsLayerSupportedUint8Neon) |
| 127 | { |
| 128 | armnn::NeonWorkloadFactory factory; |
| 129 | IsLayerSupportedTests<armnn::NeonWorkloadFactory, armnn::DataType::QuantisedAsymm8>(&factory); |
| 130 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 131 | |
| 132 | BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedNeon) |
| 133 | { |
| 134 | std::string reasonIfUnsupported; |
| 135 | |
| 136 | bool result = IsConvertLayerSupportedTests<armnn::NeonWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 137 | armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported); |
| 138 | |
| 139 | BOOST_CHECK(result); |
| 140 | } |
| 141 | |
| 142 | BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedNeon) |
| 143 | { |
| 144 | std::string reasonIfUnsupported; |
| 145 | |
| 146 | bool result = IsConvertLayerSupportedTests<armnn::NeonWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 147 | armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported); |
| 148 | |
| 149 | BOOST_CHECK(result); |
| 150 | } |
| 151 | #endif //#ifdef ARMCOMPUTENEON_ENABLED. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 152 | |
| 153 | |
| 154 | #ifdef ARMCOMPUTECL_ENABLED |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 155 | |
| 156 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedFloat16Cl, ClContextControlFixture) |
| 157 | { |
| 158 | armnn::ClWorkloadFactory factory; |
| 159 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::Float16>(&factory); |
| 160 | } |
| 161 | |
| 162 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedFloat32Cl, ClContextControlFixture) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 163 | { |
| 164 | armnn::ClWorkloadFactory factory; |
| 165 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::Float32>(&factory); |
| 166 | } |
| 167 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 168 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedUint8Cl, ClContextControlFixture) |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 169 | { |
| 170 | armnn::ClWorkloadFactory factory; |
| 171 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::QuantisedAsymm8>(&factory); |
| 172 | } |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 173 | |
| 174 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedCl, ClContextControlFixture) |
| 175 | { |
| 176 | std::string reasonIfUnsupported; |
| 177 | |
| 178 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 179 | armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported); |
| 180 | |
| 181 | BOOST_CHECK(result); |
| 182 | } |
| 183 | |
| 184 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedFp32InputCl, ClContextControlFixture) |
| 185 | { |
| 186 | std::string reasonIfUnsupported; |
| 187 | |
| 188 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 189 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 190 | |
| 191 | BOOST_CHECK(!result); |
| 192 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Input should be Float16"); |
| 193 | } |
| 194 | |
| 195 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedFp16OutputCl, ClContextControlFixture) |
| 196 | { |
| 197 | std::string reasonIfUnsupported; |
| 198 | |
| 199 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 200 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 201 | |
| 202 | BOOST_CHECK(!result); |
| 203 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Output should be Float32"); |
| 204 | } |
| 205 | |
| 206 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedCl, ClContextControlFixture) |
| 207 | { |
| 208 | std::string reasonIfUnsupported; |
| 209 | |
| 210 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 211 | armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported); |
| 212 | |
| 213 | BOOST_CHECK(result); |
| 214 | } |
| 215 | |
| 216 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedFp16InputCl, ClContextControlFixture) |
| 217 | { |
| 218 | std::string reasonIfUnsupported; |
| 219 | |
| 220 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 221 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 222 | |
| 223 | BOOST_CHECK(!result); |
| 224 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Input should be Float32"); |
| 225 | } |
| 226 | |
| 227 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedFp32OutputCl, ClContextControlFixture) |
| 228 | { |
| 229 | std::string reasonIfUnsupported; |
| 230 | |
| 231 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 232 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 233 | |
| 234 | BOOST_CHECK(!result); |
| 235 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Output should be Float16"); |
| 236 | } |
| 237 | #endif //#ifdef ARMCOMPUTECL_ENABLED. |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 238 | |
surmeh01 | 3537c2c | 2018-05-18 16:31:43 +0100 | [diff] [blame] | 239 | BOOST_AUTO_TEST_SUITE_END() |