Conor Kennedy | 7627788 | 2019-02-26 08:29:54 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include <boost/test/unit_test.hpp> |
| 7 | #include "ParserFlatbuffersSerializeFixture.hpp" |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 8 | #include <armnnDeserializer/IDeserializer.hpp> |
Conor Kennedy | 7627788 | 2019-02-26 08:29:54 +0000 | [diff] [blame] | 9 | |
| 10 | #include <string> |
Conor Kennedy | 7627788 | 2019-02-26 08:29:54 +0000 | [diff] [blame] | 11 | |
| 12 | BOOST_AUTO_TEST_SUITE(DeserializeParser) |
| 13 | |
| 14 | struct ConstantAddFixture : public ParserFlatbuffersSerializeFixture |
| 15 | { |
| 16 | explicit ConstantAddFixture(const std::string & shape, |
| 17 | const std::string & constTensorDatatype, |
| 18 | const std::string & constData, |
| 19 | const std::string & dataType) |
| 20 | { |
| 21 | m_JsonString = R"( |
| 22 | { |
| 23 | inputIds: [0], |
| 24 | outputIds: [3], |
| 25 | layers: [ |
| 26 | { |
| 27 | layer_type: "InputLayer", |
| 28 | layer: { |
| 29 | base: { |
| 30 | layerBindingId: 0, |
| 31 | base: { |
| 32 | index: 0, |
| 33 | layerName: "InputLayer1", |
| 34 | layerType: "Input", |
| 35 | inputSlots: [{ |
| 36 | index: 0, |
| 37 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 38 | }], |
| 39 | outputSlots: [ { |
| 40 | index: 0, |
| 41 | tensorInfo: { |
| 42 | dimensions: )" + shape + R"(, |
| 43 | dataType: )" + dataType + R"( |
| 44 | }, |
| 45 | }], |
| 46 | },}}, |
| 47 | }, |
| 48 | { |
| 49 | layer_type: "ConstantLayer", |
| 50 | layer: { |
| 51 | base: { |
| 52 | index:1, |
| 53 | layerName: "ConstantLayer", |
| 54 | layerType: "Constant", |
| 55 | outputSlots: [ { |
| 56 | index: 0, |
| 57 | tensorInfo: { |
| 58 | dimensions: )" + shape + R"(, |
| 59 | dataType: )" + dataType + R"(, |
| 60 | }, |
| 61 | }], |
| 62 | inputSlots: [{ |
| 63 | index: 0, |
| 64 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 65 | }], |
| 66 | }, |
| 67 | input: { |
| 68 | info: { |
| 69 | dimensions: )" + shape + R"(, |
| 70 | dataType: )" + dataType + R"( |
| 71 | }, |
| 72 | data_type: )" + constTensorDatatype + R"(, |
| 73 | data: { |
| 74 | data: )" + constData + R"(, |
| 75 | } } |
| 76 | }, |
| 77 | }, |
| 78 | { |
| 79 | layer_type: "AdditionLayer", |
| 80 | layer : { |
| 81 | base: { |
| 82 | index:2, |
| 83 | layerName: "AdditionLayer", |
| 84 | layerType: "Addition", |
| 85 | inputSlots: [ |
| 86 | { |
| 87 | index: 0, |
| 88 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 89 | }, |
| 90 | { |
| 91 | index: 1, |
| 92 | connection: {sourceLayerIndex:1, outputSlotIndex:0 }, |
| 93 | } |
| 94 | ], |
| 95 | outputSlots: [ { |
| 96 | index: 0, |
| 97 | tensorInfo: { |
| 98 | dimensions: )" + shape + R"(, |
| 99 | dataType: )" + dataType + R"( |
| 100 | }, |
| 101 | }], |
| 102 | }}, |
| 103 | }, |
| 104 | { |
| 105 | layer_type: "OutputLayer", |
| 106 | layer: { |
| 107 | base:{ |
| 108 | layerBindingId: 0, |
| 109 | base: { |
| 110 | index: 3, |
| 111 | layerName: "OutputLayer", |
| 112 | layerType: "Output", |
| 113 | inputSlots: [{ |
| 114 | index: 0, |
| 115 | connection: {sourceLayerIndex:2, outputSlotIndex:0 }, |
| 116 | }], |
| 117 | outputSlots: [ { |
| 118 | index: 0, |
| 119 | tensorInfo: { |
| 120 | dimensions: )" + shape + R"(, |
| 121 | dataType: )" + dataType + R"( |
| 122 | }, |
| 123 | }], |
| 124 | }}}, |
| 125 | }] |
| 126 | } |
| 127 | )"; |
| 128 | SetupSingleInputSingleOutput("InputLayer1", "OutputLayer"); |
| 129 | } |
| 130 | }; |
| 131 | |
| 132 | struct SimpleConstantAddFixture : ConstantAddFixture |
| 133 | { |
| 134 | SimpleConstantAddFixture() |
| 135 | : ConstantAddFixture("[ 2, 3 ]", // shape |
| 136 | "ByteData", // constDataType |
| 137 | "[ 1, 2, 3, 4, 5, 6 ]", // constData |
| 138 | "QuantisedAsymm8") // datatype |
| 139 | |
| 140 | {} |
| 141 | }; |
| 142 | |
| 143 | BOOST_FIXTURE_TEST_CASE(SimpleConstantAddQuantisedAsymm8, SimpleConstantAddFixture) |
| 144 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 145 | RunTest<2, armnn::DataType::QAsymmU8>( |
Conor Kennedy | 7627788 | 2019-02-26 08:29:54 +0000 | [diff] [blame] | 146 | 0, |
| 147 | { 1, 2, 3, 4, 5, 6 }, |
| 148 | { 2, 4, 6, 8, 10, 12 }); |
| 149 | } |
| 150 | |
| 151 | BOOST_AUTO_TEST_SUITE_END() |