surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | 93e4898 | 2018-09-05 13:05:09 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 4 | // |
| 5 | #include "DriverTestHelpers.hpp" |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 6 | |
| 7 | #include "../1.0/HalPolicy.hpp" |
| 8 | |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 9 | #include <boost/test/unit_test.hpp> |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 10 | |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 11 | #include <log/log.h> |
| 12 | |
| 13 | BOOST_AUTO_TEST_SUITE(GenericLayerTests) |
| 14 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 15 | using namespace android::hardware; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 16 | using namespace driverTestHelpers; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 17 | using namespace armnn_driver; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 18 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 19 | using HalPolicy = hal_1_0::HalPolicy; |
| 20 | |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 21 | BOOST_AUTO_TEST_CASE(GetSupportedOperations) |
| 22 | { |
| 23 | auto driver = std::make_unique<ArmnnDriver>(DriverOptions(armnn::Compute::CpuRef)); |
| 24 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 25 | ErrorStatus errorStatus; |
| 26 | std::vector<bool> supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 27 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 28 | auto cb = [&](ErrorStatus _errorStatus, const std::vector<bool>& _supported) |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 29 | { |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 30 | errorStatus = _errorStatus; |
| 31 | supported = _supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 32 | }; |
| 33 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 34 | HalPolicy::Model model0 = {}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 35 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 36 | // Add operands |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 37 | int32_t actValue = 0; |
| 38 | float weightValue[] = {2, 4, 1}; |
| 39 | float biasValue[] = {4}; |
| 40 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 41 | AddInputOperand<HalPolicy>(model0, hidl_vec<uint32_t>{1, 3}); |
| 42 | AddTensorOperand<HalPolicy>(model0, hidl_vec<uint32_t>{1, 3}, weightValue); |
| 43 | AddTensorOperand<HalPolicy>(model0, hidl_vec<uint32_t>{1}, biasValue); |
| 44 | AddIntOperand<HalPolicy>(model0, actValue); |
| 45 | AddOutputOperand<HalPolicy>(model0, hidl_vec<uint32_t>{1, 1}); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 46 | |
| 47 | model0.operations.resize(1); |
| 48 | |
| 49 | // Make a correct fully connected operation |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 50 | model0.operations[0].type = HalPolicy::OperationType::FULLY_CONNECTED; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 51 | model0.operations[0].inputs = hidl_vec<uint32_t>{0, 1, 2, 3}; |
| 52 | model0.operations[0].outputs = hidl_vec<uint32_t>{4}; |
| 53 | |
| 54 | driver->getSupportedOperations(model0, cb); |
| 55 | BOOST_TEST((int)errorStatus == (int)ErrorStatus::NONE); |
| 56 | BOOST_TEST(supported.size() == (size_t)1); |
| 57 | BOOST_TEST(supported[0] == true); |
| 58 | |
Matteo Martincigh | 8b287c2 | 2018-09-07 09:25:10 +0100 | [diff] [blame] | 59 | V1_0::Model model1 = {}; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 60 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 61 | AddInputOperand<HalPolicy>(model1, hidl_vec<uint32_t>{1, 3}); |
| 62 | AddTensorOperand<HalPolicy>(model1, hidl_vec<uint32_t>{1, 3}, weightValue); |
| 63 | AddTensorOperand<HalPolicy>(model1, hidl_vec<uint32_t>{1}, biasValue); |
| 64 | AddIntOperand<HalPolicy>(model1, actValue); |
| 65 | AddOutputOperand<HalPolicy>(model1, hidl_vec<uint32_t>{1, 1}); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 66 | |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 67 | model1.operations.resize(2); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 68 | |
| 69 | // Make a correct fully connected operation |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 70 | model1.operations[0].type = HalPolicy::OperationType::FULLY_CONNECTED; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 71 | model1.operations[0].inputs = hidl_vec<uint32_t>{0, 1, 2, 3}; |
| 72 | model1.operations[0].outputs = hidl_vec<uint32_t>{4}; |
| 73 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 74 | // Add an incorrect fully connected operation |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 75 | AddIntOperand<HalPolicy>(model1, actValue); |
| 76 | AddOutputOperand<HalPolicy>(model1, hidl_vec<uint32_t>{1, 1}); |
| 77 | |
| 78 | model1.operations[1].type = HalPolicy::OperationType::FULLY_CONNECTED; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 79 | model1.operations[1].inputs = hidl_vec<uint32_t>{4}; // Only 1 input operand, expected 4 |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 80 | model1.operations[1].outputs = hidl_vec<uint32_t>{5}; |
| 81 | |
| 82 | driver->getSupportedOperations(model1, cb); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 83 | |
Mike Kelly | b5fdf38 | 2019-06-11 16:35:25 +0100 | [diff] [blame] | 84 | #if defined(ARMNN_ANDROID_P) || defined(ARMNN_ANDROID_Q) |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 85 | // In Android P, android::nn::validateModel returns INVALID_ARGUMENT, because of the wrong number of inputs for the |
| 86 | // fully connected layer (1 instead of 4) |
| 87 | BOOST_TEST((int)errorStatus == (int)ErrorStatus::INVALID_ARGUMENT); |
| 88 | BOOST_TEST(supported.empty()); |
| 89 | #else |
| 90 | // In Android O, android::nn::validateModel indicates that the second (wrong) fully connected layer in unsupported |
| 91 | // in the vector of flags returned by the callback |
| 92 | BOOST_TEST((int)errorStatus == (int)ErrorStatus::NONE); |
| 93 | BOOST_TEST(supported.size() == (size_t)2); |
| 94 | BOOST_TEST(supported[0] == true); |
| 95 | BOOST_TEST(supported[1] == false); |
| 96 | #endif |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 97 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 98 | // Test Broadcast on add/mul operators |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 99 | HalPolicy::Model model2 = {}; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 100 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 101 | AddInputOperand<HalPolicy>(model2, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 102 | AddInputOperand<HalPolicy>(model2, hidl_vec<uint32_t>{4}); |
| 103 | AddIntOperand<HalPolicy>(model2, actValue); |
| 104 | AddOutputOperand<HalPolicy>(model2, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 105 | AddOutputOperand<HalPolicy>(model2, hidl_vec<uint32_t>{1, 1, 3, 4}); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 106 | |
| 107 | model2.operations.resize(2); |
| 108 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 109 | model2.operations[0].type = HalPolicy::OperationType::ADD; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 110 | model2.operations[0].inputs = hidl_vec<uint32_t>{0, 1, 2}; |
| 111 | model2.operations[0].outputs = hidl_vec<uint32_t>{3}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 112 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 113 | model2.operations[1].type = HalPolicy::OperationType::MUL; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 114 | model2.operations[1].inputs = hidl_vec<uint32_t>{0, 1, 2}; |
| 115 | model2.operations[1].outputs = hidl_vec<uint32_t>{4}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 116 | |
| 117 | driver->getSupportedOperations(model2, cb); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 118 | BOOST_TEST((int)errorStatus == (int)ErrorStatus::NONE); |
| 119 | BOOST_TEST(supported.size() == (size_t)2); |
| 120 | BOOST_TEST(supported[0] == true); |
| 121 | BOOST_TEST(supported[1] == true); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 122 | |
Matteo Martincigh | 8b287c2 | 2018-09-07 09:25:10 +0100 | [diff] [blame] | 123 | V1_0::Model model3 = {}; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 124 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 125 | AddInputOperand<HalPolicy>(model3, hidl_vec<uint32_t>{1, 1, 1, 8}); |
| 126 | AddIntOperand<HalPolicy>(model3, 2); |
| 127 | AddOutputOperand<HalPolicy>(model3, hidl_vec<uint32_t>{1, 2, 2, 2}); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 128 | |
| 129 | model3.operations.resize(1); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 130 | |
| 131 | // Add unsupported operation, should return no error but we don't support it |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 132 | model3.operations[0].type = HalPolicy::OperationType::DEPTH_TO_SPACE; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 133 | model3.operations[0].inputs = hidl_vec<uint32_t>{0, 1}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 134 | model3.operations[0].outputs = hidl_vec<uint32_t>{2}; |
| 135 | |
| 136 | driver->getSupportedOperations(model3, cb); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 137 | BOOST_TEST((int)errorStatus == (int)ErrorStatus::NONE); |
| 138 | BOOST_TEST(supported.size() == (size_t)1); |
| 139 | BOOST_TEST(supported[0] == false); |
| 140 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 141 | HalPolicy::Model model4 = {}; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 142 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 143 | AddIntOperand<HalPolicy>(model4, 0); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 144 | |
| 145 | model4.operations.resize(1); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 146 | |
| 147 | // Add invalid operation |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 148 | model4.operations[0].type = static_cast<HalPolicy::OperationType>(100); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 149 | model4.operations[0].outputs = hidl_vec<uint32_t>{0}; |
| 150 | |
| 151 | driver->getSupportedOperations(model4, cb); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 152 | BOOST_TEST((int)errorStatus == (int)ErrorStatus::INVALID_ARGUMENT); |
| 153 | BOOST_TEST(supported.empty()); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 154 | } |
| 155 | |
| 156 | // The purpose of this test is to ensure that when encountering an unsupported operation |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 157 | // it is skipped and getSupportedOperations() continues (rather than failing and stopping). |
| 158 | // As per IVGCVSW-710. |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 159 | BOOST_AUTO_TEST_CASE(UnsupportedLayerContinueOnFailure) |
| 160 | { |
| 161 | auto driver = std::make_unique<ArmnnDriver>(DriverOptions(armnn::Compute::CpuRef)); |
| 162 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 163 | ErrorStatus errorStatus; |
| 164 | std::vector<bool> supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 165 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 166 | auto cb = [&](ErrorStatus _errorStatus, const std::vector<bool>& _supported) |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 167 | { |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 168 | errorStatus = _errorStatus; |
| 169 | supported = _supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 170 | }; |
| 171 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 172 | HalPolicy::Model model = {}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 173 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 174 | // Operands |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 175 | int32_t actValue = 0; |
| 176 | float weightValue[] = {2, 4, 1}; |
| 177 | float biasValue[] = {4}; |
| 178 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 179 | // HASHTABLE_LOOKUP is unsupported at the time of writing this test, but any unsupported layer will do |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 180 | AddInputOperand<HalPolicy>(model, |
| 181 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
| 182 | HalPolicy::OperandType::TENSOR_INT32); |
| 183 | AddInputOperand<HalPolicy>(model, |
| 184 | hidl_vec<uint32_t>{4}, |
| 185 | HalPolicy::OperandType::TENSOR_INT32); |
| 186 | AddInputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 187 | |
| 188 | AddOutputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 189 | AddOutputOperand<HalPolicy>(model, |
| 190 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
Ellen Norris-Thompson | 976ad3e | 2019-08-21 15:21:14 +0100 | [diff] [blame] | 191 | HalPolicy::OperandType::TENSOR_QUANT8_ASYMM, |
| 192 | 1.f / 225.f); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 193 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 194 | // Fully connected is supported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 195 | AddInputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 3}); |
| 196 | |
| 197 | AddTensorOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 3}, weightValue); |
| 198 | AddTensorOperand<HalPolicy>(model, hidl_vec<uint32_t>{1}, biasValue); |
| 199 | |
| 200 | AddIntOperand<HalPolicy>(model, actValue); |
| 201 | |
| 202 | AddOutputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1}); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 203 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 204 | // EMBEDDING_LOOKUP is unsupported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 205 | AddOutputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1, 3, 4}); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 206 | |
| 207 | model.operations.resize(3); |
| 208 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 209 | // Unsupported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 210 | model.operations[0].type = HalPolicy::OperationType::HASHTABLE_LOOKUP; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 211 | model.operations[0].inputs = hidl_vec<uint32_t>{0, 1, 2}; |
| 212 | model.operations[0].outputs = hidl_vec<uint32_t>{3, 4}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 213 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 214 | // Supported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 215 | model.operations[1].type = HalPolicy::OperationType::FULLY_CONNECTED; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 216 | model.operations[1].inputs = hidl_vec<uint32_t>{5, 6, 7, 8}; |
| 217 | model.operations[1].outputs = hidl_vec<uint32_t>{9}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 218 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 219 | // Unsupported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 220 | model.operations[2].type = HalPolicy::OperationType::EMBEDDING_LOOKUP; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 221 | model.operations[2].inputs = hidl_vec<uint32_t>{1, 2}; |
| 222 | model.operations[2].outputs = hidl_vec<uint32_t>{10}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 223 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 224 | // We are testing that the unsupported layers return false and the test continues rather than failing and stopping |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 225 | driver->getSupportedOperations(model, cb); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 226 | BOOST_TEST((int)errorStatus == (int)ErrorStatus::NONE); |
| 227 | BOOST_TEST(supported.size() == (size_t)3); |
| 228 | BOOST_TEST(supported[0] == false); |
| 229 | BOOST_TEST(supported[1] == true); |
| 230 | BOOST_TEST(supported[2] == false); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 231 | } |
| 232 | |
| 233 | // The purpose of this test is to ensure that when encountering an failure |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 234 | // during mem pool mapping we properly report an error to the framework via a callback |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 235 | BOOST_AUTO_TEST_CASE(ModelToINetworkConverterMemPoolFail) |
| 236 | { |
Nikhil Raj | 7760582 | 2018-09-03 11:25:56 +0100 | [diff] [blame] | 237 | auto driver = std::make_unique<ArmnnDriver>(DriverOptions(armnn::Compute::CpuRef)); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 238 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 239 | ErrorStatus errorStatus; |
| 240 | std::vector<bool> supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 241 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 242 | auto cb = [&](ErrorStatus _errorStatus, const std::vector<bool>& _supported) |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 243 | { |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 244 | errorStatus = _errorStatus; |
| 245 | supported = _supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 246 | }; |
| 247 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 248 | HalPolicy::Model model = {}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 249 | |
| 250 | model.pools = hidl_vec<hidl_memory>{hidl_memory("Unsuported hidl memory type", nullptr, 0)}; |
| 251 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 252 | // Memory pool mapping should fail, we should report an error |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 253 | driver->getSupportedOperations(model, cb); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 254 | BOOST_TEST((int)errorStatus != (int)ErrorStatus::NONE); |
| 255 | BOOST_TEST(supported.empty()); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 256 | } |
| 257 | |
| 258 | BOOST_AUTO_TEST_SUITE_END() |