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 | |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 25 | V1_0::ErrorStatus errorStatus; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 26 | std::vector<bool> supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 27 | |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 28 | auto cb = [&](V1_0::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); |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 55 | BOOST_TEST((int)errorStatus == (int)V1_0::ErrorStatus::NONE); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 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 | |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 84 | BOOST_TEST((int)errorStatus == (int)V1_0::ErrorStatus::INVALID_ARGUMENT); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 85 | BOOST_TEST(supported.empty()); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 86 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 87 | // Test Broadcast on add/mul operators |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 88 | HalPolicy::Model model2 = {}; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 89 | |
David Monahan | c60d0fd | 2020-05-19 14:58:34 +0100 | [diff] [blame^] | 90 | AddInputOperand<HalPolicy>(model2, |
| 91 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
| 92 | HalPolicy::OperandType::TENSOR_FLOAT32, |
| 93 | 0.0f, |
| 94 | 0, |
| 95 | 2); |
| 96 | AddInputOperand<HalPolicy>(model2, |
| 97 | hidl_vec<uint32_t>{4}, |
| 98 | HalPolicy::OperandType::TENSOR_FLOAT32, |
| 99 | 0.0f, |
| 100 | 0, |
| 101 | 2); |
| 102 | AddIntOperand<HalPolicy>(model2, actValue, 2); |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 103 | AddOutputOperand<HalPolicy>(model2, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 104 | AddOutputOperand<HalPolicy>(model2, hidl_vec<uint32_t>{1, 1, 3, 4}); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 105 | |
| 106 | model2.operations.resize(2); |
| 107 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 108 | model2.operations[0].type = HalPolicy::OperationType::ADD; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 109 | model2.operations[0].inputs = hidl_vec<uint32_t>{0, 1, 2}; |
| 110 | model2.operations[0].outputs = hidl_vec<uint32_t>{3}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 111 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 112 | model2.operations[1].type = HalPolicy::OperationType::MUL; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 113 | model2.operations[1].inputs = hidl_vec<uint32_t>{0, 1, 2}; |
| 114 | model2.operations[1].outputs = hidl_vec<uint32_t>{4}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 115 | |
| 116 | driver->getSupportedOperations(model2, cb); |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 117 | BOOST_TEST((int)errorStatus == (int)V1_0::ErrorStatus::NONE); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 118 | BOOST_TEST(supported.size() == (size_t)2); |
| 119 | BOOST_TEST(supported[0] == true); |
| 120 | BOOST_TEST(supported[1] == true); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 121 | |
Matteo Martincigh | 8b287c2 | 2018-09-07 09:25:10 +0100 | [diff] [blame] | 122 | V1_0::Model model3 = {}; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 123 | |
Aron Virginas-Tar | 8edb16d | 2019-10-01 13:34:59 +0100 | [diff] [blame] | 124 | AddInputOperand<HalPolicy>(model3, |
| 125 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
| 126 | HalPolicy::OperandType::TENSOR_INT32); |
| 127 | AddInputOperand<HalPolicy>(model3, |
| 128 | hidl_vec<uint32_t>{4}, |
| 129 | HalPolicy::OperandType::TENSOR_INT32); |
| 130 | AddInputOperand<HalPolicy>(model3, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 131 | |
| 132 | AddOutputOperand<HalPolicy>(model3, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 133 | AddOutputOperand<HalPolicy>(model3, |
| 134 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
| 135 | HalPolicy::OperandType::TENSOR_QUANT8_ASYMM, |
| 136 | 1.f / 225.f); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 137 | |
| 138 | model3.operations.resize(1); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 139 | |
| 140 | // 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] | 141 | model3.operations[0].type = HalPolicy::OperationType::HASHTABLE_LOOKUP; |
| 142 | model3.operations[0].inputs = hidl_vec<uint32_t>{0, 1, 2}; |
| 143 | model3.operations[0].outputs = hidl_vec<uint32_t>{3, 4}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 144 | |
| 145 | driver->getSupportedOperations(model3, cb); |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 146 | BOOST_TEST((int)errorStatus == (int)V1_0::ErrorStatus::NONE); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 147 | BOOST_TEST(supported.size() == (size_t)1); |
| 148 | BOOST_TEST(supported[0] == false); |
| 149 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 150 | HalPolicy::Model model4 = {}; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 151 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 152 | AddIntOperand<HalPolicy>(model4, 0); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 153 | |
| 154 | model4.operations.resize(1); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 155 | |
| 156 | // Add invalid operation |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 157 | model4.operations[0].type = static_cast<HalPolicy::OperationType>(100); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 158 | model4.operations[0].outputs = hidl_vec<uint32_t>{0}; |
| 159 | |
| 160 | driver->getSupportedOperations(model4, cb); |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 161 | BOOST_TEST((int)errorStatus == (int)V1_0::ErrorStatus::INVALID_ARGUMENT); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 162 | BOOST_TEST(supported.empty()); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 163 | } |
| 164 | |
| 165 | // 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] | 166 | // it is skipped and getSupportedOperations() continues (rather than failing and stopping). |
| 167 | // As per IVGCVSW-710. |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 168 | BOOST_AUTO_TEST_CASE(UnsupportedLayerContinueOnFailure) |
| 169 | { |
| 170 | auto driver = std::make_unique<ArmnnDriver>(DriverOptions(armnn::Compute::CpuRef)); |
| 171 | |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 172 | V1_0::ErrorStatus errorStatus; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 173 | std::vector<bool> supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 174 | |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 175 | auto cb = [&](V1_0::ErrorStatus _errorStatus, const std::vector<bool>& _supported) |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 176 | { |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 177 | errorStatus = _errorStatus; |
| 178 | supported = _supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 179 | }; |
| 180 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 181 | HalPolicy::Model model = {}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 182 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 183 | // Operands |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 184 | int32_t actValue = 0; |
| 185 | float weightValue[] = {2, 4, 1}; |
| 186 | float biasValue[] = {4}; |
| 187 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 188 | // 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] | 189 | AddInputOperand<HalPolicy>(model, |
| 190 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
| 191 | HalPolicy::OperandType::TENSOR_INT32); |
| 192 | AddInputOperand<HalPolicy>(model, |
| 193 | hidl_vec<uint32_t>{4}, |
David Monahan | c60d0fd | 2020-05-19 14:58:34 +0100 | [diff] [blame^] | 194 | HalPolicy::OperandType::TENSOR_INT32, |
| 195 | 0.0f, |
| 196 | 0, |
| 197 | 2); |
| 198 | AddInputOperand<HalPolicy>(model, |
| 199 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
| 200 | HalPolicy::OperandType::TENSOR_FLOAT32, |
| 201 | 0.0f, |
| 202 | 0, |
| 203 | 2); |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 204 | |
| 205 | AddOutputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1, 3, 4}); |
| 206 | AddOutputOperand<HalPolicy>(model, |
| 207 | hidl_vec<uint32_t>{1, 1, 3, 4}, |
Ellen Norris-Thompson | 976ad3e | 2019-08-21 15:21:14 +0100 | [diff] [blame] | 208 | HalPolicy::OperandType::TENSOR_QUANT8_ASYMM, |
| 209 | 1.f / 225.f); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 210 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 211 | // Fully connected is supported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 212 | AddInputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 3}); |
| 213 | |
| 214 | AddTensorOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 3}, weightValue); |
| 215 | AddTensorOperand<HalPolicy>(model, hidl_vec<uint32_t>{1}, biasValue); |
| 216 | |
| 217 | AddIntOperand<HalPolicy>(model, actValue); |
| 218 | |
| 219 | AddOutputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1}); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 220 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 221 | // EMBEDDING_LOOKUP is unsupported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 222 | AddOutputOperand<HalPolicy>(model, hidl_vec<uint32_t>{1, 1, 3, 4}); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 223 | |
| 224 | model.operations.resize(3); |
| 225 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 226 | // Unsupported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 227 | model.operations[0].type = HalPolicy::OperationType::HASHTABLE_LOOKUP; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 228 | model.operations[0].inputs = hidl_vec<uint32_t>{0, 1, 2}; |
| 229 | model.operations[0].outputs = hidl_vec<uint32_t>{3, 4}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 230 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 231 | // Supported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 232 | model.operations[1].type = HalPolicy::OperationType::FULLY_CONNECTED; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 233 | model.operations[1].inputs = hidl_vec<uint32_t>{5, 6, 7, 8}; |
| 234 | model.operations[1].outputs = hidl_vec<uint32_t>{9}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 235 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 236 | // Unsupported |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 237 | model.operations[2].type = HalPolicy::OperationType::EMBEDDING_LOOKUP; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 238 | model.operations[2].inputs = hidl_vec<uint32_t>{1, 2}; |
| 239 | model.operations[2].outputs = hidl_vec<uint32_t>{10}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 240 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 241 | // 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] | 242 | driver->getSupportedOperations(model, cb); |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 243 | BOOST_TEST((int)errorStatus == (int)V1_0::ErrorStatus::NONE); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 244 | BOOST_TEST(supported.size() == (size_t)3); |
| 245 | BOOST_TEST(supported[0] == false); |
| 246 | BOOST_TEST(supported[1] == true); |
| 247 | BOOST_TEST(supported[2] == false); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | // The purpose of this test is to ensure that when encountering an failure |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 251 | // 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] | 252 | BOOST_AUTO_TEST_CASE(ModelToINetworkConverterMemPoolFail) |
| 253 | { |
Nikhil Raj | 7760582 | 2018-09-03 11:25:56 +0100 | [diff] [blame] | 254 | auto driver = std::make_unique<ArmnnDriver>(DriverOptions(armnn::Compute::CpuRef)); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 255 | |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 256 | V1_0::ErrorStatus errorStatus; |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 257 | std::vector<bool> supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 258 | |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 259 | auto cb = [&](V1_0::ErrorStatus _errorStatus, const std::vector<bool>& _supported) |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 260 | { |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 261 | errorStatus = _errorStatus; |
| 262 | supported = _supported; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 263 | }; |
| 264 | |
Aron Virginas-Tar | 44cfd84 | 2019-06-14 15:45:03 +0100 | [diff] [blame] | 265 | HalPolicy::Model model = {}; |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 266 | |
| 267 | model.pools = hidl_vec<hidl_memory>{hidl_memory("Unsuported hidl memory type", nullptr, 0)}; |
| 268 | |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 269 | // Memory pool mapping should fail, we should report an error |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 270 | driver->getSupportedOperations(model, cb); |
Kevin May | ec1e5b8 | 2020-02-26 17:00:39 +0000 | [diff] [blame] | 271 | BOOST_TEST((int)errorStatus != (int)V1_0::ErrorStatus::NONE); |
telsoa01 | ce3e84a | 2018-08-31 09:31:35 +0100 | [diff] [blame] | 272 | BOOST_TEST(supported.empty()); |
surmeh01 | 49b9e10 | 2018-05-17 14:11:25 +0100 | [diff] [blame] | 273 | } |
| 274 | |
| 275 | BOOST_AUTO_TEST_SUITE_END() |