1 // 2 // Copyright © 2021 Arm Ltd and Contributors. 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_Convolution3d") 12 { 13 struct Convolution3dFixture : public ParserFlatbuffersSerializeFixture 14 { Convolution3dFixtureConvolution3dFixture15 explicit Convolution3dFixture(const std::string& inputShape, 16 const std::string& outputShape, 17 const std::string& weightsShape, 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 layerName: "InputLayer", 32 layerType: "Input", 33 inputSlots: [ 34 35 ], 36 outputSlots: [ 37 { 38 tensorInfo: { 39 dimensions: )" + inputShape + R"(, 40 dataType: )" + dataType + R"(, 41 quantizationScale: 0.1, 42 dimensionSpecificity: [ 43 true, 44 true, 45 true, 46 true, 47 true 48 ] 49 } 50 } 51 ] 52 } 53 } 54 } 55 }, 56 { 57 layer_type: "ConstantLayer", 58 layer: { 59 base: { 60 index: 1, 61 layerName: "Weights", 62 layerType: "Constant", 63 inputSlots: [ 64 65 ], 66 outputSlots: [ 67 { 68 tensorInfo: { 69 dimensions: )" + weightsShape + R"(, 70 dataType: )" + dataType + R"(, 71 quantizationScale: 0.1, 72 dimensionSpecificity: [ 73 true, 74 true, 75 true, 76 true, 77 true 78 ] 79 } 80 } 81 ] 82 }, 83 input: { 84 info: { 85 dimensions: )" + weightsShape + R"(, 86 dataType: )" + dataType + R"(, 87 quantizationScale: 0.1, 88 dimensionSpecificity: [ 89 true, 90 true, 91 true, 92 true, 93 true 94 ] 95 }, 96 data_type: "ByteData", 97 data: { 98 data: [ 99 1, 1, 1, 100 1, 1, 1, 101 1, 1, 1, 102 103 0, 0, 0, 104 0, 0, 0, 105 0, 0, 0, 106 107 0, 0, 0, 108 0, 0, 0, 109 0, 0, 0 110 ] 111 } 112 } 113 } 114 }, 115 { 116 layer_type: "Convolution3dLayer", 117 layer: { 118 base: { 119 index: 2, 120 layerName: "convolution3d", 121 layerType: "Convolution3d", 122 inputSlots: [ 123 { 124 connection: { 125 sourceLayerIndex: 0, 126 outputSlotIndex: 0 127 } 128 }, 129 { 130 index: 1, 131 connection: { 132 sourceLayerIndex: 1, 133 outputSlotIndex: 0 134 } 135 } 136 ], 137 outputSlots: [ 138 { 139 tensorInfo: { 140 dimensions: )" + outputShape + R"(, 141 dataType: )" + dataType + R"(, 142 quantizationScale: 0.1, 143 dimensionSpecificity: [ 144 true, 145 true, 146 true, 147 true, 148 true 149 ] 150 } 151 } 152 ] 153 }, 154 descriptor: { 155 strideX: 2, 156 strideY: 2, 157 strideZ: 2 158 } 159 } 160 }, 161 { 162 layer_type: "OutputLayer", 163 layer: { 164 base: { 165 layerBindingId: 2, 166 base: { 167 index: 3, 168 layerName: "OutputLayer", 169 layerType: "Output", 170 inputSlots: [ 171 { 172 connection: { 173 sourceLayerIndex: 2, 174 outputSlotIndex: 0 175 } 176 } 177 ], 178 outputSlots: [ 179 180 ] 181 } 182 } 183 } 184 } 185 ], 186 featureVersions: { 187 bindingIdsScheme: 1, 188 weightsLayoutScheme: 1, 189 constantTensorsAsInputs: 1 190 } 191 } 192 )"; 193 Setup(); 194 } 195 196 197 }; 198 199 struct SimpleConvolution3dFixture : Convolution3dFixture 200 { SimpleConvolution3dFixtureSimpleConvolution3dFixture201 SimpleConvolution3dFixture() : Convolution3dFixture( 202 "[ 1, 5, 5, 5, 1 ]", 203 "[ 1, 2, 2, 2, 1 ]", 204 "[ 3, 3, 3, 1, 1 ]", 205 "QAsymmS8") {} 206 }; 207 208 TEST_CASE_FIXTURE(SimpleConvolution3dFixture, "Convolution3dInt8") 209 { 210 RunTest<5, armnn::DataType::QAsymmS8>( 211 0, 212 {{"InputLayer", { 0, 1, 2, 3, 4, 213 5, 6, 7, 8, 9, 214 10, 11, 12, 13, 14, 215 15, 16, 17, 18, 19, 216 217 20, 21, 22, 23, 24, 218 25, 26, 27, 28, 29, 219 30, 31, 32, 33, 34, 220 35, 36, 37, 38, 39, 221 40, 41, 42, 43, 44, 222 223 45, 46, 47, 48, 49, 224 50, 51, 52, 53, 54, 225 55, 56, 57, 58, 59, 226 60, 61, 62, 63, 64, 227 65, 66, 67, 68, 69, 228 229 70, 71, 72, 73, 74, 230 75, 76, 77, 78, 79, 231 80, 81, 82, 83, 84, 232 85, 86, 87, 88, 89, 233 90, 91, 92, 93, 94, 234 95, 96, 97, 98, 99, 235 236 100, 101, 102, 103, 104, 237 105, 106, 107, 108, 109, 238 110, 111, 112, 113, 114, 239 115, 116, 117, 118, 119, 240 120, 121, 122, 123, 124 241 }}}, 242 {{"OutputLayer", {5, 7, 243 244 14, 16, 245 246 50, 52, 247 248 59, 61}}}); 249 } 250 251 } 252