FinnWilliamsArm | 4ffcc8f | 2019-09-05 14:34:20 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include <boost/test/unit_test.hpp> |
| 7 | #include "ParserFlatbuffersSerializeFixture.hpp" |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 8 | #include <armnnDeserializer/IDeserializer.hpp> |
FinnWilliamsArm | 4ffcc8f | 2019-09-05 14:34:20 +0100 | [diff] [blame] | 9 | |
| 10 | #include <string> |
FinnWilliamsArm | 4ffcc8f | 2019-09-05 14:34:20 +0100 | [diff] [blame] | 11 | |
| 12 | BOOST_AUTO_TEST_SUITE(Deserializer) |
| 13 | |
| 14 | struct AbsFixture : public ParserFlatbuffersSerializeFixture |
| 15 | { |
| 16 | explicit AbsFixture(const std::string &inputShape, |
| 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: "AbsLayer", |
| 51 | layer: { |
| 52 | base: { |
| 53 | index: 1, |
| 54 | layerName: "AbsLayer", |
| 55 | layerType: "Abs", |
| 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 | |
| 69 | } |
| 70 | }, |
| 71 | { |
| 72 | layer_type: "OutputLayer", |
| 73 | layer: { |
| 74 | base:{ |
| 75 | layerBindingId: 2, |
| 76 | base: { |
| 77 | index: 2, |
| 78 | layerName: "OutputLayer", |
| 79 | layerType: "Output", |
| 80 | inputSlots: [{ |
| 81 | index: 0, |
| 82 | connection: {sourceLayerIndex:1, outputSlotIndex:0 }, |
| 83 | }], |
| 84 | outputSlots: [{ |
| 85 | index: 0, |
| 86 | tensorInfo: { |
| 87 | dimensions: )" + outputShape + R"(, |
| 88 | dataType: )" + dataType + R"( |
| 89 | }, |
| 90 | }], |
| 91 | } |
| 92 | } |
| 93 | }, |
| 94 | } |
| 95 | ] |
| 96 | } |
| 97 | )"; |
| 98 | Setup(); |
| 99 | } |
| 100 | }; |
| 101 | |
| 102 | struct SimpleAbsFixture : AbsFixture |
| 103 | { |
| 104 | SimpleAbsFixture() |
| 105 | : AbsFixture("[ 1, 2, 2, 2 ]", // inputShape |
| 106 | "[ 1, 2, 2, 2 ]", // outputShape |
| 107 | "Float32") // dataType |
| 108 | {} |
| 109 | }; |
| 110 | |
| 111 | BOOST_FIXTURE_TEST_CASE(SimpleAbsTest, SimpleAbsFixture) |
| 112 | { |
| 113 | RunTest<4, armnn::DataType::Float32>( |
| 114 | 0, |
| 115 | {{"InputLayer", { -100.0f, -50.5f, -25.9999f, -0.5f , 0.0f, 1.5555f, 25.5f, 100.0f }}}, |
Francis Murtagh | e8ac133 | 2020-07-30 18:03:40 +0100 | [diff] [blame] | 116 | {{"OutputLayer", { 100.0f, 50.5f, 25.9999f, 0.5f , 0.0f, 1.5555f, 25.5f, 100.0f }}}); |
FinnWilliamsArm | 4ffcc8f | 2019-09-05 14:34:20 +0100 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | BOOST_AUTO_TEST_SUITE_END() |