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 | 8edb16d | 2019-10-01 13:34:59 +0100 | [diff] [blame^] | 125 | AddInputOperand<HalPolicy>(model3, |
| 126 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
| 127 | HalPolicy::OperandType::TENSOR_INT32); |
| 128 | AddInputOperand<HalPolicy>(model3, |
| 129 | hidl_vec<uint32_t>{4}, |
| 130 | HalPolicy::OperandType::TENSOR_INT32); |
| 131 | AddInputOperand<HalPolicy>(model3, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 132 | |
| 133 | AddOutputOperand<HalPolicy>(model3, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 134 | AddOutputOperand<HalPolicy>(model3, |
| 135 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
| 136 | HalPolicy::OperandType::TENSOR_QUANT8_ASYMM, |
| 137 | 1.f / 225.f); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 138 | |
| 139 | model3.operations.resize(1); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 140 | |
| 141 | // Add unsupported operation, should return no error but we don't support it |
Aron Virginas-Tar | 8edb16d | 2019-10-01 13:34:59 +0100 | [diff] [blame^] | 142 | model3.operations[0].type = HalPolicy::OperationType::HASHTABLE_LOOKUP; |
| 143 | model3.operations[0].inputs = hidl_vec<uint32_t>{0, 1, 2}; |
| 144 | model3.operations[0].outputs = hidl_vec<uint32_t>{3, 4}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 145 | |
| 146 | driver->getSupportedOperations(model3, cb); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 147 | BOOST_TEST((int)errorStatus == (int)ErrorStatus::NONE); |
| 148 | BOOST_TEST(supported.size() == (size_t)1); |
| 149 | BOOST_TEST(supported[0] == false); |
| 150 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 151 | HalPolicy::Model model4 = {}; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 152 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 153 | AddIntOperand<HalPolicy>(model4, 0); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 154 | |
| 155 | model4.operations.resize(1); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 156 | |
| 157 | // Add invalid operation |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 158 | model4.operations[0].type = static_cast<HalPolicy::OperationType>(100); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 159 | model4.operations[0].outputs = hidl_vec<uint32_t>{0}; |
| 160 | |
| 161 | driver->getSupportedOperations(model4, cb); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 162 | BOOST_TEST((int)errorStatus == (int)ErrorStatus::INVALID_ARGUMENT); |
| 163 | BOOST_TEST(supported.empty()); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | // 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] | 167 | // it is skipped and getSupportedOperations() continues (rather than failing and stopping). |
| 168 | // As per IVGCVSW-710. |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 169 | BOOST_AUTO_TEST_CASE(UnsupportedLayerContinueOnFailure) |
| 170 | { |
| 171 | auto driver = std::make_unique<ArmnnDriver>(DriverOptions(armnn::Compute::CpuRef)); |
| 172 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 173 | ErrorStatus errorStatus; |
| 174 | std::vector<bool> supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 175 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 176 | auto cb = [&](ErrorStatus _errorStatus, const std::vector<bool>& _supported) |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 177 | { |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 178 | errorStatus = _errorStatus; |
| 179 | supported = _supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 180 | }; |
| 181 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 182 | HalPolicy::Model model = {}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 183 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 184 | // Operands |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 185 | int32_t actValue = 0; |
| 186 | float weightValue[] = {2, 4, 1}; |
| 187 | float biasValue[] = {4}; |
| 188 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 189 | // 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] | 190 | AddInputOperand<HalPolicy>(model, |
| 191 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
| 192 | HalPolicy::OperandType::TENSOR_INT32); |
| 193 | AddInputOperand<HalPolicy>(model, |
| 194 | hidl_vec<uint32_t>{4}, |
| 195 | HalPolicy::OperandType::TENSOR_INT32); |
| 196 | AddInputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 197 | |
| 198 | AddOutputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 199 | AddOutputOperand<HalPolicy>(model, |
| 200 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
Ellen Norris-Thompson | 976ad3e | 2019-08-21 15:21:14 +0100 | [diff] [blame] | 201 | HalPolicy::OperandType::TENSOR_QUANT8_ASYMM, |
| 202 | 1.f / 225.f); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 203 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 204 | // Fully connected is supported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 205 | AddInputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 3}); |
| 206 | |
| 207 | AddTensorOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 3}, weightValue); |
| 208 | AddTensorOperand<HalPolicy>(model, hidl_vec<uint32_t>{1}, biasValue); |
| 209 | |
| 210 | AddIntOperand<HalPolicy>(model, actValue); |
| 211 | |
| 212 | AddOutputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1}); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 213 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 214 | // EMBEDDING_LOOKUP is unsupported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 215 | AddOutputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1, 3, 4}); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 216 | |
| 217 | model.operations.resize(3); |
| 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[0].type = HalPolicy::OperationType::HASHTABLE_LOOKUP; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 221 | model.operations[0].inputs = hidl_vec<uint32_t>{0, 1, 2}; |
| 222 | model.operations[0].outputs = hidl_vec<uint32_t>{3, 4}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 223 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 224 | // Supported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 225 | model.operations[1].type = HalPolicy::OperationType::FULLY_CONNECTED; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 226 | model.operations[1].inputs = hidl_vec<uint32_t>{5, 6, 7, 8}; |
| 227 | model.operations[1].outputs = hidl_vec<uint32_t>{9}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 228 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 229 | // Unsupported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 230 | model.operations[2].type = HalPolicy::OperationType::EMBEDDING_LOOKUP; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 231 | model.operations[2].inputs = hidl_vec<uint32_t>{1, 2}; |
| 232 | model.operations[2].outputs = hidl_vec<uint32_t>{10}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 233 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 234 | // 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] | 235 | driver->getSupportedOperations(model, cb); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 236 | BOOST_TEST((int)errorStatus == (int)ErrorStatus::NONE); |
| 237 | BOOST_TEST(supported.size() == (size_t)3); |
| 238 | BOOST_TEST(supported[0] == false); |
| 239 | BOOST_TEST(supported[1] == true); |
| 240 | BOOST_TEST(supported[2] == false); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | // The purpose of this test is to ensure that when encountering an failure |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 244 | // 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] | 245 | BOOST_AUTO_TEST_CASE(ModelToINetworkConverterMemPoolFail) |
| 246 | { |
Nikhil Raj | 7760582 | 2018-09-03 11:25:56 +0100 | [diff] [blame] | 247 | auto driver = std::make_unique<ArmnnDriver>(DriverOptions(armnn::Compute::CpuRef)); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 248 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 249 | ErrorStatus errorStatus; |
| 250 | std::vector<bool> supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 251 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 252 | auto cb = [&](ErrorStatus _errorStatus, const std::vector<bool>& _supported) |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 253 | { |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 254 | errorStatus = _errorStatus; |
| 255 | supported = _supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 256 | }; |
| 257 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 258 | HalPolicy::Model model = {}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 259 | |
| 260 | model.pools = hidl_vec<hidl_memory>{hidl_memory("Unsuported hidl memory type", nullptr, 0)}; |
| 261 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 262 | // Memory pool mapping should fail, we should report an error |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 263 | driver->getSupportedOperations(model, cb); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 264 | BOOST_TEST((int)errorStatus != (int)ErrorStatus::NONE); |
| 265 | BOOST_TEST(supported.empty()); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 266 | } |
| 267 | |
| 268 | BOOST_AUTO_TEST_SUITE_END() |