Mike Kelly | a0766c3 | 2019-02-19 17:22:07 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
Mike Kelly | a0766c3 | 2019-02-19 17:22:07 +0000 | [diff] [blame] | 6 | #include "ParserFlatbuffersSerializeFixture.hpp" |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 7 | #include <armnnDeserializer/IDeserializer.hpp> |
Mike Kelly | a0766c3 | 2019-02-19 17:22:07 +0000 | [diff] [blame] | 8 | |
| 9 | #include <string> |
Mike Kelly | a0766c3 | 2019-02-19 17:22:07 +0000 | [diff] [blame] | 10 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 11 | TEST_SUITE("Deserializer_Convolution2D") |
| 12 | { |
Mike Kelly | a0766c3 | 2019-02-19 17:22:07 +0000 | [diff] [blame] | 13 | struct Convolution2dFixture : public ParserFlatbuffersSerializeFixture |
| 14 | { |
| 15 | explicit Convolution2dFixture(const std::string & inputShape1, |
| 16 | const std::string & outputShape, |
| 17 | const std::string & weightsShape, |
| 18 | const std::string & dataType) |
| 19 | { |
| 20 | m_JsonString = R"( |
| 21 | { |
| 22 | inputIds: [0], |
| 23 | outputIds: [2], |
| 24 | layers: [{ |
| 25 | layer_type: "InputLayer", |
| 26 | layer: { |
| 27 | base: { |
| 28 | layerBindingId: 0, |
| 29 | base: { |
| 30 | index: 0, |
| 31 | layerName: "InputLayer", |
| 32 | layerType: "Input", |
| 33 | inputSlots: [{ |
| 34 | index: 0, |
| 35 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 36 | }], |
| 37 | outputSlots: [{ |
| 38 | index: 0, |
| 39 | tensorInfo: { |
| 40 | dimensions: )" + inputShape1 + R"(, |
| 41 | dataType: )" + dataType + R"(, |
| 42 | quantizationScale: 0.5, |
| 43 | quantizationOffset: 0 |
| 44 | }, |
| 45 | }] |
| 46 | }, |
| 47 | } |
| 48 | }, |
| 49 | }, |
| 50 | { |
| 51 | layer_type: "Convolution2dLayer", |
| 52 | layer : { |
| 53 | base: { |
| 54 | index:1, |
| 55 | layerName: "Convolution2dLayer", |
| 56 | layerType: "Convolution2d", |
| 57 | inputSlots: [{ |
| 58 | index: 0, |
| 59 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 60 | }], |
| 61 | outputSlots: [{ |
| 62 | index: 0, |
| 63 | tensorInfo: { |
| 64 | dimensions: )" + outputShape + R"(, |
| 65 | dataType: )" + dataType + R"( |
| 66 | }, |
| 67 | }], |
| 68 | }, |
| 69 | descriptor: { |
| 70 | padLeft: 1, |
| 71 | padRight: 1, |
| 72 | padTop: 1, |
| 73 | padBottom: 1, |
| 74 | strideX: 2, |
| 75 | strideY: 2, |
| 76 | biasEnabled: false, |
| 77 | dataLayout: NHWC |
| 78 | }, |
| 79 | weights: { |
| 80 | info: { |
| 81 | dimensions: )" + weightsShape + R"(, |
| 82 | dataType: )" + dataType + R"( |
| 83 | }, |
| 84 | data_type: IntData, |
| 85 | data: { |
| 86 | data: [ |
| 87 | 1082130432, 1084227584, 1086324736, |
| 88 | 0 ,0 ,0 , |
| 89 | 1077936128, 1073741824, 1065353216 |
| 90 | ], |
| 91 | } |
| 92 | } |
| 93 | }, |
| 94 | }, |
| 95 | { |
| 96 | layer_type: "OutputLayer", |
| 97 | layer: { |
| 98 | base:{ |
| 99 | layerBindingId: 0, |
| 100 | base: { |
| 101 | index: 2, |
| 102 | layerName: "OutputLayer", |
| 103 | layerType: "Output", |
| 104 | inputSlots: [{ |
| 105 | index: 0, |
| 106 | connection: {sourceLayerIndex:1, outputSlotIndex:0 }, |
| 107 | }], |
| 108 | outputSlots: [ { |
| 109 | index: 0, |
| 110 | tensorInfo: { |
| 111 | dimensions: )" + outputShape + R"(, |
| 112 | dataType: )" + dataType + R"( |
| 113 | }, |
| 114 | }], |
| 115 | } |
| 116 | }}, |
| 117 | }] |
| 118 | } |
| 119 | )"; |
| 120 | Setup(); |
| 121 | } |
| 122 | }; |
| 123 | |
| 124 | struct SimpleConvolution2dFixture : Convolution2dFixture |
| 125 | { |
| 126 | SimpleConvolution2dFixture() : Convolution2dFixture("[ 1, 5, 5, 1 ]", |
| 127 | "[ 1, 3, 3, 1 ]", |
| 128 | "[ 1, 3, 3, 1 ]", |
| 129 | "Float32") {} |
| 130 | }; |
| 131 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 132 | TEST_CASE_FIXTURE(SimpleConvolution2dFixture, "Convolution2dFloat32") |
Mike Kelly | a0766c3 | 2019-02-19 17:22:07 +0000 | [diff] [blame] | 133 | { |
| 134 | RunTest<4, armnn::DataType::Float32>( |
| 135 | 0, |
| 136 | {{"InputLayer", {1, 5, 2, 3, 5, 8, 7, 3, 6, 3, 3, 3, 9, 1, 9, 4, 1, 8, 1, 3, 6, 8, 1, 9, 2}}}, |
| 137 | {{"OutputLayer", {23, 33, 24, 91, 99, 48, 26, 50, 19}}}); |
| 138 | } |
| 139 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 140 | } |