Nattapat Chaimanowong | ebb0f9c | 2019-03-01 12:14:06 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
Nattapat Chaimanowong | ebb0f9c | 2019-03-01 12:14:06 +0000 | [diff] [blame] | 6 | #include "ParserFlatbuffersSerializeFixture.hpp" |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 7 | #include <armnnDeserializer/IDeserializer.hpp> |
Nattapat Chaimanowong | ebb0f9c | 2019-03-01 12:14:06 +0000 | [diff] [blame] | 8 | |
| 9 | #include <string> |
| 10 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 11 | TEST_SUITE("Deserializer_Pad") |
| 12 | { |
Nattapat Chaimanowong | ebb0f9c | 2019-03-01 12:14:06 +0000 | [diff] [blame] | 13 | struct PadFixture : public ParserFlatbuffersSerializeFixture |
| 14 | { |
| 15 | explicit PadFixture(const std::string &inputShape, |
| 16 | const std::string &padList, |
| 17 | const std::string &outputShape, |
| 18 | const std::string &dataType) |
| 19 | { |
| 20 | m_JsonString = R"( |
| 21 | { |
| 22 | inputIds: [0], |
| 23 | outputIds: [2], |
| 24 | layers: [ |
| 25 | { |
| 26 | layer_type: "InputLayer", |
| 27 | layer: { |
| 28 | base: { |
| 29 | layerBindingId: 0, |
| 30 | base: { |
| 31 | index: 0, |
| 32 | layerName: "InputLayer", |
| 33 | layerType: "Input", |
| 34 | inputSlots: [{ |
| 35 | index: 0, |
| 36 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 37 | }], |
| 38 | outputSlots: [{ |
| 39 | index: 0, |
| 40 | tensorInfo: { |
| 41 | dimensions: )" + inputShape + R"(, |
| 42 | dataType: )" + dataType + R"( |
| 43 | } |
| 44 | }] |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | }, |
| 49 | { |
| 50 | layer_type: "PadLayer", |
| 51 | layer: { |
| 52 | base: { |
| 53 | index: 1, |
| 54 | layerName: "PadLayer", |
| 55 | layerType: "Pad", |
| 56 | inputSlots: [{ |
| 57 | index: 0, |
| 58 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 59 | }], |
| 60 | outputSlots: [{ |
| 61 | index: 0, |
| 62 | tensorInfo: { |
| 63 | dimensions: )" + outputShape + R"(, |
| 64 | dataType: )" + dataType + R"( |
| 65 | } |
| 66 | }] |
| 67 | }, |
| 68 | descriptor: { |
| 69 | padList: )" + padList + R"(, |
| 70 | } |
| 71 | } |
| 72 | }, |
| 73 | { |
| 74 | layer_type: "OutputLayer", |
| 75 | layer: { |
| 76 | base:{ |
| 77 | layerBindingId: 2, |
| 78 | base: { |
| 79 | index: 2, |
| 80 | layerName: "OutputLayer", |
| 81 | layerType: "Output", |
| 82 | inputSlots: [{ |
| 83 | index: 0, |
| 84 | connection: {sourceLayerIndex:1, outputSlotIndex:0 }, |
| 85 | }], |
| 86 | outputSlots: [{ |
| 87 | index: 0, |
| 88 | tensorInfo: { |
| 89 | dimensions: )" + outputShape + R"(, |
| 90 | dataType: )" + dataType + R"( |
| 91 | }, |
| 92 | }], |
| 93 | } |
| 94 | } |
| 95 | }, |
| 96 | } |
| 97 | ] |
| 98 | } |
| 99 | )"; |
| 100 | SetupSingleInputSingleOutput("InputLayer", "OutputLayer"); |
| 101 | } |
| 102 | }; |
| 103 | |
| 104 | struct SimplePadFixture : PadFixture |
| 105 | { |
| 106 | SimplePadFixture() : PadFixture("[ 2, 2, 2 ]", |
| 107 | "[ 0, 1, 2, 1, 2, 2 ]", |
| 108 | "[ 3, 5, 6 ]", |
| 109 | "QuantisedAsymm8") {} |
| 110 | }; |
| 111 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 112 | TEST_CASE_FIXTURE(SimplePadFixture, "SimplePadQuantisedAsymm8") |
Nattapat Chaimanowong | ebb0f9c | 2019-03-01 12:14:06 +0000 | [diff] [blame] | 113 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 114 | RunTest<3, armnn::DataType::QAsymmU8>(0, |
Nattapat Chaimanowong | ebb0f9c | 2019-03-01 12:14:06 +0000 | [diff] [blame] | 115 | { |
| 116 | 0, 4, 2, 5, 6, 1, 5, 2 |
| 117 | }, |
| 118 | { |
| 119 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 120 | 4, 0, 0, 0, 0, 2, 5, 0, 0, 0, 0, 0, 0, 0, 0, |
| 121 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, |
| 122 | 1, 0, 0, 0, 0, 5, 2, 0, 0, 0, 0, 0, 0, 0, 0, |
| 123 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 124 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 |
| 125 | }); |
| 126 | } |
| 127 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 128 | } |