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 | |
| 39 | BOOST_FIXTURE_TEST_CASE(IsLayerSupportedUint8Cl, ClContextControlFixture) |
| 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 | |
| 46 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedCl, ClContextControlFixture) |
| 47 | { |
| 48 | std::string reasonIfUnsupported; |
| 49 | |
| 50 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 51 | armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported); |
| 52 | |
| 53 | BOOST_CHECK(result); |
| 54 | } |
| 55 | |
| 56 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedFp32InputCl, ClContextControlFixture) |
| 57 | { |
| 58 | std::string reasonIfUnsupported; |
| 59 | |
| 60 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 61 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 62 | |
| 63 | BOOST_CHECK(!result); |
| 64 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Input should be Float16"); |
| 65 | } |
| 66 | |
| 67 | BOOST_FIXTURE_TEST_CASE(IsConvertFp16ToFp32SupportedFp16OutputCl, ClContextControlFixture) |
| 68 | { |
| 69 | std::string reasonIfUnsupported; |
| 70 | |
| 71 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 72 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 73 | |
| 74 | BOOST_CHECK(!result); |
| 75 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Output should be Float32"); |
| 76 | } |
| 77 | |
| 78 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedCl, ClContextControlFixture) |
| 79 | { |
| 80 | std::string reasonIfUnsupported; |
| 81 | |
| 82 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 83 | armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported); |
| 84 | |
| 85 | BOOST_CHECK(result); |
| 86 | } |
| 87 | |
| 88 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedFp16InputCl, ClContextControlFixture) |
| 89 | { |
| 90 | std::string reasonIfUnsupported; |
| 91 | |
| 92 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 93 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 94 | |
| 95 | BOOST_CHECK(!result); |
| 96 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Input should be Float32"); |
| 97 | } |
| 98 | |
| 99 | BOOST_FIXTURE_TEST_CASE(IsConvertFp32ToFp16SupportedFp32OutputCl, ClContextControlFixture) |
| 100 | { |
| 101 | std::string reasonIfUnsupported; |
| 102 | |
| 103 | bool result = IsConvertLayerSupportedTests<armnn::ClWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 104 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 105 | |
| 106 | BOOST_CHECK(!result); |
| 107 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Output should be Float16"); |
| 108 | } |
| 109 | |
Matthew Bentham | 1f0ff35 | 2019-01-02 13:26:31 +0000 | [diff] [blame] | 110 | BOOST_FIXTURE_TEST_CASE(IsMeanSupportedCl, ClContextControlFixture) |
| 111 | { |
| 112 | std::string reasonIfUnsupported; |
| 113 | |
| 114 | bool result = IsMeanLayerSupportedTests<armnn::ClWorkloadFactory, |
| 115 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 116 | |
| 117 | BOOST_CHECK(result); |
| 118 | } |
| 119 | |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 120 | BOOST_AUTO_TEST_SUITE_END() |