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