1 // 2 // Copyright © 2017 Arm Ltd. All rights reserved. 3 // SPDX-License-Identifier: MIT 4 // 5 6 #include "ParserFlatbuffersSerializeFixture.hpp" 7 #include <armnnDeserializer/IDeserializer.hpp> 8 9 #include <doctest/doctest.h> 10 11 #include <string> 12 13 TEST_SUITE("Deserializer_Abs") 14 { 15 struct AbsFixture : public ParserFlatbuffersSerializeFixture 16 { AbsFixtureAbsFixture17 explicit AbsFixture(const std::string &inputShape, 18 const std::string &outputShape, 19 const std::string &dataType) 20 { 21 m_JsonString = R"( 22 { 23 inputIds: [0], 24 outputIds: [2], 25 layers: [ 26 { 27 layer_type: "InputLayer", 28 layer: { 29 base: { 30 layerBindingId: 0, 31 base: { 32 index: 0, 33 layerName: "InputLayer", 34 layerType: "Input", 35 inputSlots: [{ 36 index: 0, 37 connection: {sourceLayerIndex:0, outputSlotIndex:0 }, 38 }], 39 outputSlots: [{ 40 index: 0, 41 tensorInfo: { 42 dimensions: )" + inputShape + R"(, 43 dataType: )" + dataType + R"( 44 } 45 }] 46 } 47 } 48 } 49 }, 50 { 51 layer_type: "AbsLayer", 52 layer: { 53 base: { 54 index: 1, 55 layerName: "AbsLayer", 56 layerType: "Abs", 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 70 } 71 }, 72 { 73 layer_type: "OutputLayer", 74 layer: { 75 base:{ 76 layerBindingId: 2, 77 base: { 78 index: 2, 79 layerName: "OutputLayer", 80 layerType: "Output", 81 inputSlots: [{ 82 index: 0, 83 connection: {sourceLayerIndex:1, outputSlotIndex:0 }, 84 }], 85 outputSlots: [{ 86 index: 0, 87 tensorInfo: { 88 dimensions: )" + outputShape + R"(, 89 dataType: )" + dataType + R"( 90 }, 91 }], 92 } 93 } 94 }, 95 } 96 ] 97 } 98 )"; 99 Setup(); 100 } 101 }; 102 103 struct SimpleAbsFixture : AbsFixture 104 { SimpleAbsFixtureSimpleAbsFixture105 SimpleAbsFixture() 106 : AbsFixture("[ 1, 2, 2, 2 ]", // inputShape 107 "[ 1, 2, 2, 2 ]", // outputShape 108 "Float32") // dataType 109 {} 110 }; 111 112 TEST_CASE_FIXTURE(SimpleAbsFixture, "SimpleAbsTest") 113 { 114 RunTest<4, armnn::DataType::Float32>( 115 0, 116 {{"InputLayer", { -100.0f, -50.5f, -25.9999f, -0.5f , 0.0f, 1.5555f, 25.5f, 100.0f }}}, 117 {{"OutputLayer", { 100.0f, 50.5f, 25.9999f, 0.5f , 0.0f, 1.5555f, 25.5f, 100.0f }}}); 118 } 119 120 }