Nattapat Chaimanowong | 6b4ed98 | 2019-02-26 17:24:13 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
Nattapat Chaimanowong | 6b4ed98 | 2019-02-26 17:24:13 +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 | 6b4ed98 | 2019-02-26 17:24:13 +0000 | [diff] [blame] | 8 | |
| 9 | #include <string> |
| 10 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 11 | TEST_SUITE("Deserializer_BatchToSpaceND") |
| 12 | { |
Nattapat Chaimanowong | 6b4ed98 | 2019-02-26 17:24:13 +0000 | [diff] [blame] | 13 | struct BatchToSpaceNdFixture : public ParserFlatbuffersSerializeFixture |
| 14 | { |
| 15 | explicit BatchToSpaceNdFixture(const std::string &inputShape, |
| 16 | const std::string &blockShape, |
| 17 | const std::string &crops, |
| 18 | const std::string &dataLayout, |
| 19 | const std::string &outputShape, |
| 20 | const std::string &dataType) |
| 21 | { |
| 22 | m_JsonString = R"( |
| 23 | { |
| 24 | inputIds: [0], |
| 25 | outputIds: [2], |
| 26 | layers: [ |
| 27 | { |
| 28 | layer_type: "InputLayer", |
| 29 | layer: { |
| 30 | base: { |
| 31 | layerBindingId: 0, |
| 32 | base: { |
| 33 | index: 0, |
| 34 | layerName: "InputLayer", |
| 35 | layerType: "Input", |
| 36 | inputSlots: [{ |
| 37 | index: 0, |
| 38 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 39 | }], |
| 40 | outputSlots: [{ |
| 41 | index: 0, |
| 42 | tensorInfo: { |
| 43 | dimensions: )" + inputShape + R"(, |
| 44 | dataType: )" + dataType + R"( |
| 45 | } |
| 46 | }] |
| 47 | } |
| 48 | } |
| 49 | } |
| 50 | }, |
| 51 | { |
| 52 | layer_type: "BatchToSpaceNdLayer", |
| 53 | layer: { |
| 54 | base: { |
| 55 | index: 1, |
| 56 | layerName: "BatchToSpaceNdLayer", |
| 57 | layerType: "BatchToSpaceNd", |
| 58 | inputSlots: [{ |
| 59 | index: 0, |
| 60 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 61 | }], |
| 62 | outputSlots: [{ |
| 63 | index: 0, |
| 64 | tensorInfo: { |
| 65 | dimensions: )" + outputShape + R"(, |
| 66 | dataType: )" + dataType + R"( |
| 67 | } |
| 68 | }] |
| 69 | }, |
| 70 | descriptor: { |
| 71 | blockShape: )" + blockShape + R"(, |
| 72 | crops: )" + crops + R"(, |
| 73 | dataLayout: )" + dataLayout + R"(, |
| 74 | } |
| 75 | } |
| 76 | }, |
| 77 | { |
| 78 | layer_type: "OutputLayer", |
| 79 | layer: { |
| 80 | base:{ |
| 81 | layerBindingId: 2, |
| 82 | base: { |
| 83 | index: 2, |
| 84 | layerName: "OutputLayer", |
| 85 | layerType: "Output", |
| 86 | inputSlots: [{ |
| 87 | index: 0, |
| 88 | connection: {sourceLayerIndex:1, outputSlotIndex:0 }, |
| 89 | }], |
| 90 | outputSlots: [{ |
| 91 | index: 0, |
| 92 | tensorInfo: { |
| 93 | dimensions: )" + outputShape + R"(, |
| 94 | dataType: )" + dataType + R"( |
| 95 | }, |
| 96 | }], |
| 97 | } |
| 98 | } |
| 99 | }, |
| 100 | } |
| 101 | ] |
| 102 | } |
| 103 | )"; |
| 104 | SetupSingleInputSingleOutput("InputLayer", "OutputLayer"); |
| 105 | } |
| 106 | }; |
| 107 | |
| 108 | struct SimpleBatchToSpaceNdFixture : BatchToSpaceNdFixture |
| 109 | { |
| 110 | SimpleBatchToSpaceNdFixture() : BatchToSpaceNdFixture("[ 4, 2, 2, 1 ]", |
| 111 | "[ 2, 2 ]", |
| 112 | "[ 0, 0, 0, 0 ]", |
| 113 | "NHWC", |
| 114 | "[ 1, 4, 4, 1 ]", |
| 115 | "Float32") {} |
| 116 | }; |
| 117 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 118 | TEST_CASE_FIXTURE(SimpleBatchToSpaceNdFixture, "SimpleBatchToSpaceNdFloat32") |
Nattapat Chaimanowong | 6b4ed98 | 2019-02-26 17:24:13 +0000 | [diff] [blame] | 119 | { |
| 120 | RunTest<4, armnn::DataType::Float32>(0, |
| 121 | { |
| 122 | 1.0f, 3.0f, 9.0f, 11.0f, |
| 123 | 2.0f, 4.0f, 10.0f, 12.0f, |
| 124 | 5.0f, 7.0f, 13.0f, 15.0f, |
| 125 | 6.0f, 8.0f, 14.0f, 16.0f |
| 126 | }, |
| 127 | { |
| 128 | 1.0f, 2.0f, 3.0f, 4.0f, |
| 129 | 5.0f, 6.0f, 7.0f, 8.0f, |
| 130 | 9.0f, 10.0f, 11.0f, 12.0f, |
| 131 | 13.0f, 14.0f, 15.0f, 16.0f |
| 132 | }); |
| 133 | } |
| 134 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 135 | } |