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