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 | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 6 | #include <layers/ConvertFp16ToFp32Layer.hpp> |
| 7 | #include <layers/ConvertFp32ToFp16Layer.hpp> |
| 8 | #include <test/TensorHelpers.hpp> |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 9 | |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 10 | #include <backendsCommon/CpuTensorHandle.hpp> |
| 11 | #include <reference/RefWorkloadFactory.hpp> |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 12 | #include <reference/RefLayerSupport.hpp> |
Aron Virginas-Tar | c9cc804 | 2018-11-01 16:15:57 +0000 | [diff] [blame] | 13 | #include <backendsCommon/test/LayerTests.hpp> |
| 14 | #include <backendsCommon/test/IsLayerSupportedTestImpl.hpp> |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 15 | |
| 16 | #include <boost/test/unit_test.hpp> |
| 17 | |
| 18 | #include <string> |
| 19 | |
| 20 | namespace |
| 21 | { |
| 22 | |
| 23 | bool LayerTypeMatchesTest() |
| 24 | { |
| 25 | return LayerTypeMatchesTestImpl<armnn::LayerType::FirstLayer>(Tag<armnn::LayerType::FirstLayer>()); |
| 26 | }; |
| 27 | |
| 28 | } // anonymous namespace |
| 29 | |
| 30 | BOOST_AUTO_TEST_SUITE(RefLayerSupported) |
| 31 | |
| 32 | BOOST_AUTO_TEST_CASE(IsLayerSupportedLayerTypeMatches) |
| 33 | { |
| 34 | LayerTypeMatchesTest(); |
| 35 | } |
Derek Lamberti | 50db4e8 | 2019-03-13 14:16:15 +0000 | [diff] [blame] | 36 | BOOST_AUTO_TEST_CASE(IsLayerSupportedReferenceAddition) |
| 37 | { |
| 38 | armnn::TensorShape shape0 = {1,1,3,4}; |
| 39 | armnn::TensorShape shape1 = {4}; |
| 40 | armnn::TensorShape outShape = {1,1,3,4}; |
| 41 | armnn::TensorInfo in0(shape0, armnn::DataType::Float32); |
| 42 | armnn::TensorInfo in1(shape1, armnn::DataType::Float32); |
| 43 | armnn::TensorInfo out(outShape, armnn::DataType::Float32); |
| 44 | |
| 45 | armnn::RefLayerSupport supportChecker; |
| 46 | std::string reasonNotSupported; |
| 47 | BOOST_CHECK(supportChecker.IsAdditionSupported(in0, in1, out, reasonNotSupported)); |
| 48 | } |
| 49 | |
arovir01 | 43095f3 | 2018-10-09 18:04:24 +0100 | [diff] [blame] | 50 | |
| 51 | BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat16Reference) |
| 52 | { |
| 53 | armnn::RefWorkloadFactory factory; |
| 54 | IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float16>(&factory); |
| 55 | } |
| 56 | |
| 57 | BOOST_AUTO_TEST_CASE(IsLayerSupportedFloat32Reference) |
| 58 | { |
| 59 | armnn::RefWorkloadFactory factory; |
| 60 | IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::Float32>(&factory); |
| 61 | } |
| 62 | |
| 63 | BOOST_AUTO_TEST_CASE(IsLayerSupportedUint8Reference) |
| 64 | { |
| 65 | armnn::RefWorkloadFactory factory; |
| 66 | IsLayerSupportedTests<armnn::RefWorkloadFactory, armnn::DataType::QuantisedAsymm8>(&factory); |
| 67 | } |
| 68 | |
| 69 | BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedReference) |
| 70 | { |
| 71 | std::string reasonIfUnsupported; |
| 72 | |
| 73 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 74 | armnn::DataType::Float16, armnn::DataType::Float32>(reasonIfUnsupported); |
| 75 | |
| 76 | BOOST_CHECK(result); |
| 77 | } |
| 78 | |
| 79 | BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedFp32InputReference) |
| 80 | { |
| 81 | std::string reasonIfUnsupported; |
| 82 | |
| 83 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 84 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 85 | |
| 86 | BOOST_CHECK(!result); |
| 87 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type input"); |
| 88 | } |
| 89 | |
| 90 | BOOST_AUTO_TEST_CASE(IsConvertFp16ToFp32SupportedFp16OutputReference) |
| 91 | { |
| 92 | std::string reasonIfUnsupported; |
| 93 | |
| 94 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp16ToFp32Layer, |
| 95 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 96 | |
| 97 | BOOST_CHECK(!result); |
| 98 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type output"); |
| 99 | } |
| 100 | |
| 101 | BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedReference) |
| 102 | { |
| 103 | std::string reasonIfUnsupported; |
| 104 | |
| 105 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 106 | armnn::DataType::Float32, armnn::DataType::Float16>(reasonIfUnsupported); |
| 107 | |
| 108 | BOOST_CHECK(result); |
| 109 | } |
| 110 | |
| 111 | BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedFp16InputReference) |
| 112 | { |
| 113 | std::string reasonIfUnsupported; |
| 114 | |
| 115 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 116 | armnn::DataType::Float16, armnn::DataType::Float16>(reasonIfUnsupported); |
| 117 | |
| 118 | BOOST_CHECK(!result); |
| 119 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float16 data type input"); |
| 120 | } |
| 121 | |
| 122 | BOOST_AUTO_TEST_CASE(IsConvertFp32ToFp16SupportedFp32OutputReference) |
| 123 | { |
| 124 | std::string reasonIfUnsupported; |
| 125 | |
| 126 | bool result = IsConvertLayerSupportedTests<armnn::RefWorkloadFactory, armnn::ConvertFp32ToFp16Layer, |
| 127 | armnn::DataType::Float32, armnn::DataType::Float32>(reasonIfUnsupported); |
| 128 | |
| 129 | BOOST_CHECK(!result); |
| 130 | BOOST_CHECK_EQUAL(reasonIfUnsupported, "Layer is not supported with float32 data type output"); |
| 131 | } |
| 132 | |
| 133 | BOOST_AUTO_TEST_SUITE_END() |