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> |
Matthew Bentham | 1f0ff35 | 2019-01-02 13:26:31 +0000 | [diff] [blame] | 10 | #include <layers/MeanLayer.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 11 | #include <test/TensorHelpers.hpp> |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 12 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 13 | #include <backendsCommon/CpuTensorHandle.hpp> |
| 14 | #include <cl/ClWorkloadFactory.hpp> |
| 15 | #include <cl/test/ClContextControlFixture.hpp> |
| 16 | #include <backendsCommon/test/IsLayerSupportedTestImpl.hpp> |
| 17 | #include <backendsCommon/test/LayerTests.hpp> |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 18 | |
| 19 | #include <boost/test/unit_test.hpp> |
| 20 | |
| 21 | #include <string> |
| 22 | |
| 23 | BOOST_AUTO_TEST_SUITE(ClLayerSupport) |
| 24 | |
| 25 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedFloat16Cl, ClContextControlFixture) |
| 26 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 27 | armnn::ClWorkloadFactory factory = |
| 28 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 29 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::Float16>(&factory); |
| 30 | } |
| 31 | |
| 32 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedFloat32Cl, ClContextControlFixture) |
| 33 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 34 | armnn::ClWorkloadFactory factory = |
| 35 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 36 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::Float32>(&factory); |
| 37 | } |
| 38 | |
Keith Davis | a856501 | 2020-02-14 12:22:40 +0000 | [diff] [blame] | 39 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedQAsymmU8Cl, ClContextControlFixture) |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 40 | { |
Aron Virginas-Tar | 5caf907 | 2018-11-14 18:35:18 +0000 | [diff] [blame] | 41 | armnn::ClWorkloadFactory factory = |
| 42 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 43 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::QAsymmU8>(&factory); |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 44 | } |
| 45 | |
Keith Davis | a856501 | 2020-02-14 12:22:40 +0000 | [diff] [blame] | 46 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedQAsymmS8Cl, ClContextControlFixture) |
| 47 | { |
| 48 | armnn::ClWorkloadFactory factory = |
| 49 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 50 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::QAsymmS8>(&factory); |
| 51 | } |
| 52 | |
| 53 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedQSymmS8Cl, ClContextControlFixture) |
Keith Davis | 9d0ff74 | 2020-02-03 14:47:54 +0000 | [diff] [blame] | 54 | { |
| 55 | armnn::ClWorkloadFactory factory = |
| 56 | ClWorkloadFactoryHelper::GetFactory(ClWorkloadFactoryHelper::GetMemoryManager()); |
| 57 | IsLayerSupportedTests<armnn::ClWorkloadFactory, armnn::DataType::QSymmS8>(&factory); |
| 58 | } |
| 59 | |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 60 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedCl, ClContextControlFixture) |
| 61 | { |
| 62 | std::string reasonIfUnsupported; |
| 63 | |
| 64 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 65 | armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported); |
| 66 | |
| 67 | BOOST_CHECK(result); |
| 68 | } |
| 69 | |
| 70 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedFp32InputCl, ClContextControlFixture) |
| 71 | { |
| 72 | std::string reasonIfUnsupported; |
| 73 | |
| 74 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 75 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 76 | |
| 77 | BOOST_CHECK(!result); |
| 78 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Input should be Float16"); |
| 79 | } |
| 80 | |
| 81 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedFp16OutputCl, ClContextControlFixture) |
| 82 | { |
| 83 | std::string reasonIfUnsupported; |
| 84 | |
| 85 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 86 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 87 | |
| 88 | BOOST_CHECK(!result); |
| 89 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Output should be Float32"); |
| 90 | } |
| 91 | |
| 92 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedCl, ClContextControlFixture) |
| 93 | { |
| 94 | std::string reasonIfUnsupported; |
| 95 | |
| 96 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 97 | armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported); |
| 98 | |
| 99 | BOOST_CHECK(result); |
| 100 | } |
| 101 | |
| 102 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedFp16InputCl, ClContextControlFixture) |
| 103 | { |
| 104 | std::string reasonIfUnsupported; |
| 105 | |
| 106 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 107 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 108 | |
| 109 | BOOST_CHECK(!result); |
| 110 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Input should be Float32"); |
| 111 | } |
| 112 | |
| 113 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedFp32OutputCl, ClContextControlFixture) |
| 114 | { |
| 115 | std::string reasonIfUnsupported; |
| 116 | |
| 117 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 118 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 119 | |
| 120 | BOOST_CHECK(!result); |
| 121 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Output should be Float16"); |
| 122 | } |
| 123 | |
Matthew Bentham | 1f0ff35 | 2019-01-02 13:26:31 +0000 | [diff] [blame] | 124 | BOOST_FIXTURE_TEST_CASE(IsMeanSupportedCl, ClContextControlFixture) |
| 125 | { |
| 126 | std::string reasonIfUnsupported; |
| 127 | |
| 128 | bool result = IsMeanLayerSupportedTests<armnn::ClWorkloadFactory, |
| 129 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 130 | |
| 131 | BOOST_CHECK(result); |
| 132 | } |
| 133 | |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 134 | BOOST_AUTO_TEST_SUITE_END() |