Saoirse Stewart | 263829c | 2019-02-19 15:54:14 +0000 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
Saoirse Stewart | 263829c | 2019-02-19 15:54:14 +0000 | [diff] [blame] | 6 | #include "ParserFlatbuffersSerializeFixture.hpp" |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 7 | #include <armnnDeserializer/IDeserializer.hpp> |
Saoirse Stewart | 263829c | 2019-02-19 15:54:14 +0000 | [diff] [blame] | 8 | |
| 9 | #include <string> |
Saoirse Stewart | 263829c | 2019-02-19 15:54:14 +0000 | [diff] [blame] | 10 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 11 | TEST_SUITE("Deserializer_Reshape") |
| 12 | { |
Saoirse Stewart | 263829c | 2019-02-19 15:54:14 +0000 | [diff] [blame] | 13 | struct ReshapeFixture : public ParserFlatbuffersSerializeFixture |
| 14 | { |
| 15 | explicit ReshapeFixture(const std::string &inputShape, |
| 16 | const std::string &targetShape, |
| 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 | layer_type: "ReshapeLayer", |
| 48 | layer: { |
| 49 | base: { |
| 50 | index: 1, |
| 51 | layerName: "ReshapeLayer", |
| 52 | layerType: "Reshape", |
| 53 | inputSlots: [{ |
| 54 | index: 0, |
| 55 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 56 | }], |
| 57 | outputSlots: [ { |
| 58 | index: 0, |
| 59 | tensorInfo: { |
| 60 | dimensions: )" + inputShape + R"(, |
| 61 | dataType: )" + dataType + R"( |
| 62 | |
| 63 | }}]}, |
| 64 | descriptor: { |
| 65 | targetShape: )" + targetShape + R"(, |
| 66 | } |
| 67 | |
| 68 | }}, |
| 69 | { |
| 70 | layer_type: "OutputLayer", |
| 71 | layer: { |
| 72 | base:{ |
| 73 | layerBindingId: 2, |
| 74 | base: { |
| 75 | index: 2, |
| 76 | layerName: "OutputLayer", |
| 77 | layerType: "Output", |
| 78 | inputSlots: [{ |
| 79 | index: 0, |
| 80 | connection: {sourceLayerIndex:0, outputSlotIndex:0 }, |
| 81 | }], |
| 82 | outputSlots: [ { |
| 83 | index: 0, |
| 84 | tensorInfo: { |
| 85 | dimensions: )" + outputShape + R"(, |
| 86 | dataType: )" + dataType + R"( |
| 87 | }, |
| 88 | }], |
| 89 | }}}, |
| 90 | }] |
| 91 | } |
| 92 | )"; |
| 93 | SetupSingleInputSingleOutput("InputLayer", "OutputLayer"); |
| 94 | } |
| 95 | }; |
| 96 | |
| 97 | struct SimpleReshapeFixture : ReshapeFixture |
| 98 | { |
| 99 | SimpleReshapeFixture() : ReshapeFixture("[ 1, 9 ]", "[ 3, 3 ]", "[ 3, 3 ]", |
| 100 | "QuantisedAsymm8") {} |
| 101 | }; |
| 102 | |
| 103 | struct SimpleReshapeFixture2 : ReshapeFixture |
| 104 | { |
| 105 | SimpleReshapeFixture2() : ReshapeFixture("[ 2, 2, 1, 1 ]", |
| 106 | "[ 2, 2, 1, 1 ]", |
| 107 | "[ 2, 2, 1, 1 ]", |
| 108 | "Float32") {} |
| 109 | }; |
| 110 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 111 | TEST_CASE_FIXTURE(SimpleReshapeFixture, "ReshapeQuantisedAsymm8") |
Saoirse Stewart | 263829c | 2019-02-19 15:54:14 +0000 | [diff] [blame] | 112 | { |
Derek Lamberti | f90c56d | 2020-01-10 17:14:08 +0000 | [diff] [blame] | 113 | RunTest<2, armnn::DataType::QAsymmU8>(0, |
Saoirse Stewart | 263829c | 2019-02-19 15:54:14 +0000 | [diff] [blame] | 114 | { 1, 2, 3, 4, 5, 6, 7, 8, 9 }, |
| 115 | { 1, 2, 3, 4, 5, 6, 7, 8, 9 }); |
| 116 | } |
| 117 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 118 | TEST_CASE_FIXTURE(SimpleReshapeFixture2, "ReshapeFloat32") |
Saoirse Stewart | 263829c | 2019-02-19 15:54:14 +0000 | [diff] [blame] | 119 | { |
| 120 | RunTest<4, armnn::DataType::Float32>(0, |
| 121 | { 111, 85, 226, 3 }, |
| 122 | { 111, 85, 226, 3 }); |
| 123 | } |
| 124 | |
| 125 | |
Sadik Armagan | 1625efc | 2021-06-10 18:24:34 +0100 | [diff] [blame] | 126 | } |