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 <string> 10 11 TEST_SUITE("Deserializer_Division") 12 { 13 struct DivisionFixture : public ParserFlatbuffersSerializeFixture 14 { DivisionFixtureDivisionFixture15 explicit DivisionFixture(const std::string & inputShape1, 16 const std::string & inputShape2, 17 const std::string & outputShape, 18 const std::string & dataType) 19 { 20 m_JsonString = R"( 21 { 22 inputIds: [0, 1], 23 outputIds: [3], 24 layers: [ 25 { 26 layer_type: "InputLayer", 27 layer: { 28 base: { 29 layerBindingId: 0, 30 base: { 31 index: 0, 32 layerName: "InputLayer1", 33 layerType: "Input", 34 inputSlots: [{ 35 index: 0, 36 connection: {sourceLayerIndex:0, outputSlotIndex:0 }, 37 }], 38 outputSlots: [ { 39 index: 0, 40 tensorInfo: { 41 dimensions: )" + inputShape1 + R"(, 42 dataType: )" + dataType + R"( 43 }, 44 }], 45 },}}, 46 }, 47 { 48 layer_type: "InputLayer", 49 layer: { 50 base: { 51 layerBindingId: 1, 52 base: { 53 index:1, 54 layerName: "InputLayer2", 55 layerType: "Input", 56 inputSlots: [{ 57 index: 0, 58 connection: {sourceLayerIndex:0, outputSlotIndex:0 }, 59 }], 60 outputSlots: [ { 61 index: 0, 62 tensorInfo: { 63 dimensions: )" + inputShape2 + R"(, 64 dataType: )" + dataType + R"( 65 }, 66 }], 67 },}}, 68 }, 69 { 70 layer_type: "DivisionLayer", 71 layer : { 72 base: { 73 index:2, 74 layerName: "DivisionLayer", 75 layerType: "Division", 76 inputSlots: [ 77 { 78 index: 0, 79 connection: {sourceLayerIndex:0, outputSlotIndex:0 }, 80 }, 81 { 82 index: 1, 83 connection: {sourceLayerIndex:1, outputSlotIndex:0 }, 84 } 85 ], 86 outputSlots: [ { 87 index: 0, 88 tensorInfo: { 89 dimensions: )" + outputShape + R"(, 90 dataType: )" + dataType + R"( 91 }, 92 }], 93 }}, 94 }, 95 { 96 layer_type: "OutputLayer", 97 layer: { 98 base:{ 99 layerBindingId: 0, 100 base: { 101 index: 3, 102 layerName: "OutputLayer", 103 layerType: "Output", 104 inputSlots: [{ 105 index: 0, 106 connection: {sourceLayerIndex:2, outputSlotIndex:0 }, 107 }], 108 outputSlots: [ { 109 index: 0, 110 tensorInfo: { 111 dimensions: )" + outputShape + R"(, 112 dataType: )" + dataType + R"( 113 }, 114 }], 115 }}}, 116 }] 117 } 118 )"; 119 Setup(); 120 } 121 }; 122 123 124 struct SimpleDivisionFixture : DivisionFixture 125 { SimpleDivisionFixtureSimpleDivisionFixture126 SimpleDivisionFixture() : DivisionFixture("[ 2, 2 ]", 127 "[ 2, 2 ]", 128 "[ 2, 2 ]", 129 "QuantisedAsymm8") {} 130 }; 131 132 struct SimpleDivisionFixture2 : DivisionFixture 133 { SimpleDivisionFixture2SimpleDivisionFixture2134 SimpleDivisionFixture2() : DivisionFixture("[ 2, 2, 1, 1 ]", 135 "[ 2, 2, 1, 1 ]", 136 "[ 2, 2, 1, 1 ]", 137 "Float32") {} 138 }; 139 140 TEST_CASE_FIXTURE(SimpleDivisionFixture, "DivisionQuantisedAsymm8") 141 { 142 RunTest<2, armnn::DataType::QAsymmU8>( 143 0, 144 {{"InputLayer1", { 0, 5, 24, 21 }}, 145 {"InputLayer2", { 4, 1, 6, 7 }}}, 146 {{"OutputLayer", { 0, 5, 3, 3 }}}); 147 } 148 149 TEST_CASE_FIXTURE(SimpleDivisionFixture2, "DivisionFloat32") 150 { 151 RunTest<4, armnn::DataType::Float32>( 152 0, 153 {{"InputLayer1", { 100, 40, 226, 9 }}, 154 {"InputLayer2", { 5, 8, 1, 3 }}}, 155 {{"OutputLayer", { 20, 5, 226, 3 }}}); 156 } 157 158 } 159