arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
Aron Virginas-Tar | 5605519 | 2018-11-12 18:10:43 +0000 | [diff] [blame] | 6 | #include "ClWorkloadFactoryHelper.hpp" |
| 7 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 8 | #include <layers/ConvertFp16ToFp32Layer.hpp> |
| 9 | #include <layers/ConvertFp32ToFp16Layer.hpp> |
| 10 | #include <test/TensorHelpers.hpp> |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 11 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 12 | #include <backendsCommon/CpuTensorHandle.hpp> |
| 13 | #include <cl/ClWorkloadFactory.hpp> |
| 14 | #include <cl/test/ClContextControlFixture.hpp> |
| 15 | #include <backendsCommon/test/IsLayerSupportedTestImpl.hpp> |
| 16 | #include <backendsCommon/test/LayerTests.hpp> |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 17 | |
| 18 | #include <boost/test/unit_test.hpp> |
| 19 | |
| 20 | #include <string> |
| 21 | |
| 22 | BOOST_AUTO_TEST_SUITE(ClLayerSupport) |
| 23 | |
| 24 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedFloat16Cl, ClContextControlFixture) |
| 25 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 26 | armnn::ClWorkloadFactory factory = |
| 27 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 28 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::Float16>(&factory); |
| 29 | } |
| 30 | |
| 31 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedFloat32Cl, ClContextControlFixture) |
| 32 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 33 | armnn::ClWorkloadFactory factory = |
| 34 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 35 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::Float32>(&factory); |
| 36 | } |
| 37 | |
| 38 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedUint8Cl, ClContextControlFixture) |
| 39 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 40 | armnn::ClWorkloadFactory factory = |
| 41 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 42 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::QuantisedAsymm8>(&factory); |
| 43 | } |
| 44 | |
| 45 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedCl, ClContextControlFixture) |
| 46 | { |
| 47 | std::string reasonIfUnsupported; |
| 48 | |
| 49 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 50 | armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported); |
| 51 | |
| 52 | BOOST_CHECK(result); |
| 53 | } |
| 54 | |
| 55 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedFp32InputCl, ClContextControlFixture) |
| 56 | { |
| 57 | std::string reasonIfUnsupported; |
| 58 | |
| 59 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 60 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 61 | |
| 62 | BOOST_CHECK(!result); |
| 63 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Input should be Float16"); |
| 64 | } |
| 65 | |
| 66 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedFp16OutputCl, ClContextControlFixture) |
| 67 | { |
| 68 | std::string reasonIfUnsupported; |
| 69 | |
| 70 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 71 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 72 | |
| 73 | BOOST_CHECK(!result); |
| 74 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Output should be Float32"); |
| 75 | } |
| 76 | |
| 77 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedCl, ClContextControlFixture) |
| 78 | { |
| 79 | std::string reasonIfUnsupported; |
| 80 | |
| 81 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 82 | armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported); |
| 83 | |
| 84 | BOOST_CHECK(result); |
| 85 | } |
| 86 | |
| 87 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedFp16InputCl, ClContextControlFixture) |
| 88 | { |
| 89 | std::string reasonIfUnsupported; |
| 90 | |
| 91 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 92 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 93 | |
| 94 | BOOST_CHECK(!result); |
| 95 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Input should be Float32"); |
| 96 | } |
| 97 | |
| 98 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedFp32OutputCl, ClContextControlFixture) |
| 99 | { |
| 100 | std::string reasonIfUnsupported; |
| 101 | |
| 102 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 103 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 104 | |
| 105 | BOOST_CHECK(!result); |
| 106 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Output should be Float16"); |
| 107 | } |
| 108 | |
| 109 | BOOST_AUTO_TEST_SUITE_END() |