surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 1 | // |
Teresa Charlin | 30dc2d2 | 2022-12-05 17:41:10 +0000 | [diff] [blame] | 2 | // Copyright © 2017,2022 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 4 | // |
| 5 | #include "SerializeLayerParameters.hpp" |
| 6 | #include <armnn/TypesUtils.hpp> |
| 7 | #include <string> |
| 8 | #include <iostream> |
| 9 | #include <sstream> |
| 10 | |
| 11 | namespace armnn |
| 12 | { |
| 13 | |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 14 | void StringifyLayerParameters<ActivationDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 15 | const ActivationDescriptor& desc) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 16 | { |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 17 | fn("Function", GetActivationFunctionAsCString(desc.m_Function)); |
| 18 | fn("A", std::to_string(desc.m_A)); |
| 19 | fn("B", std::to_string(desc.m_B)); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 20 | } |
| 21 | |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 22 | void StringifyLayerParameters<BatchNormalizationDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 23 | const BatchNormalizationDescriptor& desc) |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 24 | { |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 25 | fn("Eps", std::to_string(desc.m_Eps)); |
| 26 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
surmeh01 | bceff2f | 2018-03-29 16:29:27 +0100 | [diff] [blame] | 27 | } |
| 28 | |
Teresa Charlin | 30dc2d2 | 2022-12-05 17:41:10 +0000 | [diff] [blame] | 29 | void StringifyLayerParameters<BatchMatMulDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 30 | const BatchMatMulDescriptor& desc) |
| 31 | { |
| 32 | fn("TransposeX", (desc.m_TransposeX ? "true" : "false")); |
| 33 | fn("TransposeX", (desc.m_TransposeY ? "true" : "false")); |
| 34 | fn("AdjointX", (desc.m_AdjointX ? "true" : "false")); |
| 35 | fn("AdjointY", (desc.m_AdjointY ? "true" : "false")); |
| 36 | } |
| 37 | |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 38 | void StringifyLayerParameters<BatchToSpaceNdDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 39 | const BatchToSpaceNdDescriptor& desc) |
| 40 | { |
| 41 | { |
| 42 | std::stringstream ss; |
| 43 | int count = 0; |
| 44 | for (auto&& var : desc.m_BlockShape) |
| 45 | { |
| 46 | if (count > 0) |
| 47 | { |
| 48 | ss << ","; |
| 49 | } |
| 50 | ss << var; |
| 51 | ++count; |
| 52 | } |
| 53 | fn("BlockShape", ss.str()); |
| 54 | } |
| 55 | |
| 56 | { |
| 57 | std::stringstream ss; |
| 58 | int count = 0; |
| 59 | for (auto&& var : desc.m_Crops) |
| 60 | { |
| 61 | if (count > 0) |
| 62 | { |
| 63 | ss << ","; |
| 64 | } |
| 65 | ss << "[" << var.first << "," << var.second << "]"; |
| 66 | ++count; |
| 67 | } |
| 68 | fn("Crops", ss.str()); |
| 69 | } |
| 70 | |
| 71 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 72 | } |
| 73 | |
Simon Obute | 51f6777 | 2021-09-03 15:50:13 +0100 | [diff] [blame] | 74 | void StringifyLayerParameters<ChannelShuffleDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 75 | const ChannelShuffleDescriptor& desc) |
| 76 | { |
| 77 | fn("Axis", std::to_string(desc.m_Axis)); |
| 78 | fn("NumGroups", std::to_string(desc.m_NumGroups)); |
| 79 | } |
| 80 | |
Teresa Charlin | 400c593 | 2021-06-04 10:29:47 +0100 | [diff] [blame] | 81 | void StringifyLayerParameters<ComparisonDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 82 | const ComparisonDescriptor& desc) |
| 83 | { |
| 84 | fn("Operation", GetComparisonOperationAsCString(desc.m_Operation)); |
| 85 | } |
| 86 | |
| 87 | void StringifyLayerParameters<Convolution2dDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 88 | const Convolution2dDescriptor& desc) |
| 89 | { |
| 90 | { |
| 91 | std::stringstream ss; |
| 92 | ss << "(" << desc.m_PadTop << "," << desc.m_PadLeft |
| 93 | << "," << desc.m_PadBottom << "," << desc.m_PadRight << ")"; |
| 94 | fn("Padding(T,L,B,R)",ss.str()); |
| 95 | } |
| 96 | |
| 97 | { |
| 98 | std::stringstream ss; |
| 99 | ss << "(" << desc.m_StrideX << "," << desc.m_StrideY << ")"; |
| 100 | fn("Stride(X,Y)", ss.str()); |
| 101 | } |
| 102 | |
| 103 | { |
| 104 | std::stringstream ss; |
| 105 | ss << "(" << desc.m_DilationX << "," << desc.m_DilationY << ")"; |
| 106 | fn("Dilation(X,Y)", ss.str()); |
| 107 | } |
| 108 | |
| 109 | fn("BiasEnabled",(desc.m_BiasEnabled ? "true" : "false")); |
| 110 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 111 | } |
| 112 | |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 113 | void StringifyLayerParameters<Convolution3dDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 114 | const Convolution3dDescriptor& desc) |
| 115 | { |
| 116 | { |
| 117 | std::stringstream ss; |
| 118 | ss << "(" << desc.m_PadTop << "," << desc.m_PadLeft |
| 119 | << "," << desc.m_PadBottom << "," << desc.m_PadRight |
| 120 | << "," << desc.m_PadFront << "," << desc.m_PadBack << ")"; |
| 121 | fn("Padding(T,L,B,R,F,B)",ss.str()); |
| 122 | } |
| 123 | |
| 124 | { |
| 125 | std::stringstream ss; |
| 126 | ss << "(" << desc.m_StrideX << "," << desc.m_StrideY << "," << desc.m_StrideZ << ")"; |
| 127 | fn("Stride(X,Y,Z)", ss.str()); |
| 128 | } |
| 129 | |
| 130 | { |
| 131 | std::stringstream ss; |
| 132 | ss << "(" << desc.m_DilationX << "," << desc.m_DilationY << "," << desc.m_DilationZ << ")"; |
Tamas Nyiri | d998a1c | 2021-11-05 14:55:33 +0000 | [diff] [blame] | 133 | fn("Dilation(X,Y,Z)", ss.str()); |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 134 | } |
| 135 | |
| 136 | fn("BiasEnabled",(desc.m_BiasEnabled ? "true" : "false")); |
| 137 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 138 | } |
| 139 | |
Teresa Charlin | 400c593 | 2021-06-04 10:29:47 +0100 | [diff] [blame] | 140 | void StringifyLayerParameters<DetectionPostProcessDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 141 | const DetectionPostProcessDescriptor& desc) |
| 142 | { |
| 143 | fn("MaxDetections", std::to_string(desc.m_MaxDetections)); |
| 144 | fn("MaxClassesPerDetection", std::to_string(desc.m_MaxClassesPerDetection)); |
| 145 | fn("DetectionsPerClass", std::to_string(desc.m_DetectionsPerClass)); |
| 146 | fn("NmsScoreThreshold", std::to_string(desc.m_NmsScoreThreshold)); |
| 147 | fn("NmsIouThreshold", std::to_string(desc.m_NmsIouThreshold)); |
| 148 | fn("NumClasses", std::to_string(desc.m_NumClasses)); |
| 149 | fn("UseRegularNms", (desc.m_UseRegularNms ? "true" : "false")); |
| 150 | { |
| 151 | std::stringstream ss; |
| 152 | ss << "(" << desc.m_ScaleX << "," << desc.m_ScaleY << ")"; |
| 153 | fn("Scale(X,Y)", ss.str()); |
| 154 | } |
| 155 | |
| 156 | { |
| 157 | std::stringstream ss; |
| 158 | ss << "(" << desc.m_ScaleW << "," << desc.m_ScaleH << ")"; |
| 159 | fn("Scale(W,H)", ss.str()); |
| 160 | } |
| 161 | } |
| 162 | |
| 163 | void StringifyLayerParameters<DepthwiseConvolution2dDescriptor>::Serialize( |
| 164 | ParameterStringifyFunction& fn, |
| 165 | const DepthwiseConvolution2dDescriptor& desc) |
| 166 | { |
| 167 | { |
| 168 | std::stringstream ss; |
| 169 | ss << "(" << desc.m_PadTop << "," << desc.m_PadLeft |
| 170 | << "," << desc.m_PadBottom << "," << desc.m_PadRight << ")"; |
| 171 | fn("Padding(T,L,B,R)",ss.str()); |
| 172 | } |
| 173 | |
| 174 | { |
| 175 | std::stringstream ss; |
| 176 | ss << "(" << desc.m_StrideX << "," << desc.m_StrideY << ")"; |
| 177 | fn("Stride(X,Y)", ss.str()); |
| 178 | } |
| 179 | |
| 180 | { |
| 181 | std::stringstream ss; |
| 182 | ss << "(" << desc.m_DilationX << "," << desc.m_DilationY << ")"; |
| 183 | fn("Dilation(X,Y)", ss.str()); |
| 184 | } |
| 185 | |
| 186 | fn("BiasEnabled",(desc.m_BiasEnabled ? "true" : "false")); |
| 187 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 188 | } |
| 189 | |
| 190 | void StringifyLayerParameters<ElementwiseUnaryDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 191 | const ElementwiseUnaryDescriptor& desc) |
| 192 | { |
| 193 | fn("UnaryOperation", GetUnaryOperationAsCString(desc.m_Operation)); |
| 194 | } |
| 195 | |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 196 | void StringifyLayerParameters<FakeQuantizationDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 197 | const FakeQuantizationDescriptor& desc) |
| 198 | { |
| 199 | fn("Min", std::to_string(desc.m_Min)); |
| 200 | fn("Max", std::to_string(desc.m_Max)); |
| 201 | } |
| 202 | |
Teresa Charlin | 400c593 | 2021-06-04 10:29:47 +0100 | [diff] [blame] | 203 | void StringifyLayerParameters<FullyConnectedDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 204 | const FullyConnectedDescriptor& desc) |
| 205 | { |
| 206 | fn("BiasEnabled", (desc.m_BiasEnabled ? "true" : "false")); |
| 207 | fn("TransposeWeightMatrix", (desc.m_TransposeWeightMatrix ? "true" : "false")); |
| 208 | } |
| 209 | |
Teresa Charlin | 30dc2d2 | 2022-12-05 17:41:10 +0000 | [diff] [blame] | 210 | void StringifyLayerParameters<GatherDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 211 | const GatherDescriptor& desc) |
| 212 | { |
| 213 | fn("Axis", std::to_string(desc.m_Axis)); |
| 214 | } |
| 215 | |
Teresa Charlin | 400c593 | 2021-06-04 10:29:47 +0100 | [diff] [blame] | 216 | void StringifyLayerParameters<L2NormalizationDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 217 | const L2NormalizationDescriptor& desc) |
| 218 | { |
| 219 | fn("Eps", std::to_string(desc.m_Eps)); |
| 220 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 221 | } |
| 222 | |
| 223 | void StringifyLayerParameters<LstmDescriptor>::Serialize(ParameterStringifyFunction& fn, const LstmDescriptor& desc) |
| 224 | { |
| 225 | fn("ActivationFunc", std::to_string(desc.m_ActivationFunc)); |
| 226 | fn("ClippingThresCell", std::to_string(desc.m_ClippingThresCell)); |
| 227 | fn("ClippingThresProj", std::to_string(desc.m_ClippingThresProj)); |
| 228 | fn("CifgEnabled", (desc.m_CifgEnabled ? "true" : "false")) ; |
| 229 | fn("PeepholeEnabled", (desc.m_PeepholeEnabled ? "true" : "false")) ; |
| 230 | fn("ProjectionEnabled", (desc.m_ProjectionEnabled ? "true" : "false")) ; |
| 231 | fn("LayerNormEnabled", (desc.m_LayerNormEnabled ? "true" : "false")); |
| 232 | } |
| 233 | |
| 234 | void StringifyLayerParameters<MeanDescriptor>::Serialize(ParameterStringifyFunction& fn, const MeanDescriptor& desc) |
| 235 | { |
| 236 | { |
| 237 | std::stringstream ss; |
| 238 | int count = 0; |
| 239 | for (auto&& var : desc.m_Axis) |
| 240 | { |
| 241 | if (count > 0) |
| 242 | { |
| 243 | ss << ","; |
| 244 | } |
| 245 | ss << var; |
| 246 | ++count; |
| 247 | } |
| 248 | fn("Axis", ss.str()); |
| 249 | } |
| 250 | fn("KeepDims", (desc.m_KeepDims ? "true" : "false")); |
| 251 | } |
| 252 | |
| 253 | void StringifyLayerParameters<NormalizationDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 254 | const NormalizationDescriptor& desc) |
| 255 | { |
| 256 | fn("NormChannelType", GetNormalizationAlgorithmChannelAsCString(desc.m_NormChannelType)); |
| 257 | fn("NormMethodType", GetNormalizationAlgorithmMethodAsCString(desc.m_NormMethodType)); |
| 258 | fn("NormSize", std::to_string(desc.m_NormSize)); |
| 259 | fn("Alpha", std::to_string(desc.m_Alpha)); |
| 260 | fn("Beta", std::to_string(desc.m_Beta)); |
| 261 | fn("K", std::to_string(desc.m_K)); |
| 262 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 263 | } |
| 264 | |
| 265 | void StringifyLayerParameters<OriginsDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 266 | const OriginsDescriptor& desc) |
| 267 | { |
| 268 | fn("ConcatAxis", std::to_string(desc.GetConcatAxis())); |
| 269 | |
| 270 | uint32_t numViews = desc.GetNumViews(); |
| 271 | uint32_t numDims = desc.GetNumDimensions(); |
| 272 | |
| 273 | for (uint32_t view = 0; view < numViews; ++view) |
| 274 | { |
| 275 | std::stringstream key; |
| 276 | key << "MergeTo#" << view; |
| 277 | std::stringstream value; |
| 278 | value << "["; |
| 279 | auto viewData = desc.GetViewOrigin(view); |
| 280 | |
| 281 | for (uint32_t dim = 0; dim < numDims; ++dim) |
| 282 | { |
| 283 | if (dim > 0) |
| 284 | { |
| 285 | value << ","; |
| 286 | } |
| 287 | value << viewData[dim]; |
| 288 | } |
| 289 | value << "]"; |
| 290 | fn(key.str(), value.str()); |
| 291 | } |
| 292 | } |
| 293 | |
| 294 | void StringifyLayerParameters<PadDescriptor>::Serialize(ParameterStringifyFunction& fn, const PadDescriptor& desc) |
| 295 | { |
| 296 | { |
| 297 | std::stringstream ss; |
| 298 | int count = 0; |
| 299 | for (auto&& var : desc.m_PadList) |
| 300 | { |
| 301 | if (count > 0) |
| 302 | { |
| 303 | ss << ","; |
| 304 | } |
| 305 | ss << "[" << var.first << "," << var.second << "]"; |
| 306 | ++count; |
| 307 | } |
| 308 | fn("PadList", ss.str()); |
| 309 | } |
| 310 | fn("PadValue", std::to_string(desc.m_PadValue)); |
Matthew Sloyan | 2e5d0b2 | 2021-10-21 14:05:31 +0100 | [diff] [blame] | 311 | fn("PaddingMode", GetPaddingModeAsCString(desc.m_PaddingMode)); |
Teresa Charlin | 400c593 | 2021-06-04 10:29:47 +0100 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | void StringifyLayerParameters<PreCompiledDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 315 | const PreCompiledDescriptor& desc) |
| 316 | { |
| 317 | fn("NumInputSlots", std::to_string(desc.m_NumInputSlots)); |
| 318 | fn("NumOutputSlots", std::to_string(desc.m_NumOutputSlots)); |
| 319 | } |
| 320 | |
| 321 | void StringifyLayerParameters<Pooling2dDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 322 | const Pooling2dDescriptor& desc) |
| 323 | { |
| 324 | fn("Type", GetPoolingAlgorithmAsCString(desc.m_PoolType)); |
| 325 | { |
| 326 | std::stringstream ss; |
| 327 | ss << "(" << desc.m_PadTop << "," << desc.m_PadLeft |
| 328 | << "," << desc.m_PadBottom << "," << desc.m_PadRight << ")"; |
| 329 | fn("Padding(T,L,B,R)", ss.str()); |
| 330 | } |
| 331 | |
| 332 | { |
| 333 | std::stringstream ss; |
| 334 | ss << "(" << desc.m_PoolWidth << "," << desc.m_PoolHeight << ")"; |
| 335 | fn("(Width,Height)", ss.str()); |
| 336 | } |
| 337 | |
| 338 | { |
| 339 | std::stringstream ss; |
| 340 | ss << "(" << desc.m_StrideX << "," << desc.m_StrideY << ")"; |
| 341 | fn("Stride(X,Y)", ss.str()); |
| 342 | } |
| 343 | |
| 344 | fn("OutputShapeRounding", GetOutputShapeRoundingAsCString(desc.m_OutputShapeRounding)); |
| 345 | fn("PaddingMethod", GetPaddingMethodAsCString(desc.m_PaddingMethod)); |
| 346 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 347 | } |
| 348 | |
Tamas Nyiri | d998a1c | 2021-11-05 14:55:33 +0000 | [diff] [blame] | 349 | void StringifyLayerParameters<Pooling3dDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 350 | const Pooling3dDescriptor& desc) |
| 351 | { |
| 352 | fn("Type", GetPoolingAlgorithmAsCString(desc.m_PoolType)); |
| 353 | { |
| 354 | std::stringstream ss; |
| 355 | ss << "(" << desc.m_PadTop << "," << desc.m_PadLeft |
| 356 | << "," << desc.m_PadBottom << "," << desc.m_PadRight |
| 357 | << "," << desc.m_PadFront << "," << desc.m_PadBack << ")"; |
| 358 | fn("Padding(T,L,B,R,F,B)", ss.str()); |
| 359 | } |
| 360 | |
| 361 | { |
| 362 | std::stringstream ss; |
| 363 | ss << "(" << desc.m_PoolWidth << "," << desc.m_PoolHeight << "," << desc.m_PoolDepth << ")"; |
| 364 | fn("(Width,Height,Depth)", ss.str()); |
| 365 | } |
| 366 | |
| 367 | { |
| 368 | std::stringstream ss; |
| 369 | ss << "(" << desc.m_StrideX << "," << desc.m_StrideY << "," << desc.m_StrideZ << ")"; |
| 370 | fn("Stride(X,Y,Z)", ss.str()); |
| 371 | } |
| 372 | |
| 373 | fn("OutputShapeRounding", GetOutputShapeRoundingAsCString(desc.m_OutputShapeRounding)); |
| 374 | fn("PaddingMethod", GetPaddingMethodAsCString(desc.m_PaddingMethod)); |
| 375 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 376 | } |
| 377 | |
Teresa Charlin | 400c593 | 2021-06-04 10:29:47 +0100 | [diff] [blame] | 378 | void StringifyLayerParameters<PermuteDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 379 | const PermuteDescriptor& desc) |
| 380 | { |
| 381 | std::stringstream ss; |
| 382 | ss << "["; |
| 383 | bool addComma = false; |
| 384 | for (auto it : desc.m_DimMappings) |
| 385 | { |
| 386 | if (addComma) |
| 387 | { |
| 388 | ss << ","; |
| 389 | } |
| 390 | ss << it; |
| 391 | addComma = true; |
| 392 | } |
| 393 | ss << "]"; |
| 394 | |
| 395 | fn("DimMappings",ss.str()); |
| 396 | } |
| 397 | |
| 398 | void StringifyLayerParameters<ReduceDescriptor>::Serialize(ParameterStringifyFunction& fn, const ReduceDescriptor& desc) |
| 399 | { |
| 400 | { |
| 401 | std::stringstream ss; |
| 402 | int count = 0; |
| 403 | for (auto&& var : desc.m_vAxis) |
| 404 | { |
| 405 | if (count > 0) |
| 406 | { |
| 407 | ss << ","; |
| 408 | } |
| 409 | ss << var; |
| 410 | ++count; |
| 411 | } |
| 412 | fn("Axis", ss.str()); |
| 413 | } |
| 414 | fn("KeepDims", (desc.m_KeepDims ? "true" : "false")); |
| 415 | fn("ReduceOperation", GetReduceOperationAsCString(desc.m_ReduceOperation)); |
| 416 | } |
| 417 | |
| 418 | void StringifyLayerParameters<ReshapeDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 419 | const ReshapeDescriptor& desc) |
| 420 | { |
| 421 | std::stringstream ss; |
| 422 | ss << desc.m_TargetShape; |
| 423 | fn("TargetShape",ss.str()); |
| 424 | } |
| 425 | |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 426 | void StringifyLayerParameters<ResizeDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 427 | const ResizeDescriptor& desc) |
| 428 | { |
| 429 | fn("TargetWidth", std::to_string(desc.m_TargetWidth)); |
| 430 | fn("TargetHeight", std::to_string(desc.m_TargetHeight)); |
| 431 | fn("ResizeMethod", GetResizeMethodAsCString(desc.m_Method)); |
| 432 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
David Monahan | ab21975 | 2020-06-19 16:43:48 +0100 | [diff] [blame] | 433 | fn("AlignCorners", std::to_string(desc.m_AlignCorners)); |
| 434 | fn("HalfPixelCenters", std::to_string(desc.m_HalfPixelCenters)); |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 435 | } |
| 436 | |
Teresa Charlin | 400c593 | 2021-06-04 10:29:47 +0100 | [diff] [blame] | 437 | void StringifyLayerParameters<SoftmaxDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 438 | const SoftmaxDescriptor& desc) |
| 439 | { |
| 440 | fn("Beta", std::to_string(desc.m_Beta)); |
| 441 | fn("Axis", std::to_string(desc.m_Axis)); |
| 442 | } |
| 443 | |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 444 | void StringifyLayerParameters<SpaceToBatchNdDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 445 | const SpaceToBatchNdDescriptor& desc) |
| 446 | { |
| 447 | { |
| 448 | std::stringstream ss; |
| 449 | int count = 0; |
| 450 | for (auto&& var : desc.m_BlockShape) |
| 451 | { |
| 452 | if (count > 0) |
| 453 | { |
| 454 | ss << ","; |
| 455 | } |
| 456 | ss << var; |
| 457 | ++count; |
| 458 | } |
| 459 | fn("BlockShape", ss.str()); |
| 460 | } |
| 461 | |
| 462 | { |
| 463 | std::stringstream ss; |
| 464 | int count = 0; |
| 465 | for (auto&& var : desc.m_PadList) |
| 466 | { |
| 467 | if (count > 0) |
| 468 | { |
| 469 | ss << ","; |
| 470 | } |
| 471 | ss << "[" << var.first << "," << var.second << "]"; |
| 472 | ++count; |
| 473 | } |
| 474 | fn("PadList", ss.str()); |
| 475 | } |
| 476 | |
| 477 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 478 | } |
| 479 | |
| 480 | void StringifyLayerParameters<SpaceToDepthDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 481 | const SpaceToDepthDescriptor& desc) |
| 482 | { |
| 483 | fn("BlockSize", std::to_string(desc.m_BlockSize)); |
| 484 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 485 | } |
| 486 | |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 487 | void StringifyLayerParameters<StackDescriptor>::Serialize(ParameterStringifyFunction& fn, const StackDescriptor& desc) |
| 488 | { |
| 489 | fn("Axis", std::to_string(desc.m_Axis)); |
| 490 | fn("NumInputs", std::to_string(desc.m_NumInputs)); |
| 491 | { |
| 492 | std::stringstream ss; |
| 493 | ss << desc.m_InputShape; |
| 494 | fn("InputShape",ss.str()); |
| 495 | } |
| 496 | } |
| 497 | |
| 498 | void StringifyLayerParameters<StridedSliceDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 499 | const StridedSliceDescriptor& desc) |
| 500 | { |
| 501 | { |
| 502 | std::stringstream ss; |
| 503 | int count = 0; |
| 504 | for (auto&& var : desc.m_Begin) |
| 505 | { |
| 506 | if (count > 0) |
| 507 | { |
| 508 | ss << ","; |
| 509 | } |
| 510 | ss << var; |
| 511 | ++count; |
| 512 | } |
| 513 | fn("Begin", ss.str()); |
| 514 | } |
| 515 | |
| 516 | { |
| 517 | std::stringstream ss; |
| 518 | int count = 0; |
| 519 | for (auto&& var : desc.m_End) |
| 520 | { |
| 521 | if (count > 0) |
| 522 | { |
| 523 | ss << ","; |
| 524 | } |
| 525 | ss << var; |
| 526 | ++count; |
| 527 | } |
| 528 | fn("End", ss.str()); |
| 529 | } |
| 530 | |
| 531 | { |
| 532 | std::stringstream ss; |
| 533 | int count = 0; |
| 534 | for (auto&& var : desc.m_Stride) |
| 535 | { |
| 536 | if (count > 0) |
| 537 | { |
| 538 | ss << ","; |
| 539 | } |
| 540 | ss << var; |
| 541 | ++count; |
| 542 | } |
| 543 | fn("Stride", ss.str()); |
| 544 | } |
| 545 | |
| 546 | fn("BeginMask", std::to_string(desc.m_BeginMask)); |
| 547 | fn("EndMask", std::to_string(desc.m_EndMask)); |
| 548 | fn("ShrinkAxisMask", std::to_string(desc.m_ShrinkAxisMask)); |
| 549 | fn("EllipsisMask", std::to_string(desc.m_EllipsisMask)); |
| 550 | fn("NewAxisMask", std::to_string(desc.m_NewAxisMask)); |
| 551 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 552 | } |
| 553 | |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 554 | void StringifyLayerParameters<TransposeConvolution2dDescriptor>::Serialize( |
| 555 | ParameterStringifyFunction& fn, |
| 556 | const TransposeConvolution2dDescriptor& desc) |
| 557 | { |
| 558 | { |
| 559 | std::stringstream ss; |
| 560 | ss << "(" << desc.m_PadTop << "," << desc.m_PadLeft |
| 561 | << "," << desc.m_PadBottom << "," << desc.m_PadRight << ")"; |
| 562 | fn("Padding(T,L,B,R)",ss.str()); |
| 563 | } |
| 564 | |
| 565 | { |
| 566 | std::stringstream ss; |
| 567 | ss << "(" << desc.m_StrideX << "," << desc.m_StrideY << ")"; |
| 568 | fn("Stride(X,Y)", ss.str()); |
| 569 | } |
| 570 | |
| 571 | fn("BiasEnabled", (desc.m_BiasEnabled ? "true" : "false")); |
| 572 | fn("DataLayout", GetDataLayoutName(desc.m_DataLayout)); |
| 573 | } |
| 574 | |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 575 | void StringifyLayerParameters<TransposeDescriptor>::Serialize(ParameterStringifyFunction& fn, |
| 576 | const TransposeDescriptor& desc) |
| 577 | { |
| 578 | std::stringstream ss; |
| 579 | ss << "["; |
| 580 | bool addComma = false; |
| 581 | for (auto it : desc.m_DimMappings) |
| 582 | { |
| 583 | if (addComma) |
| 584 | { |
| 585 | ss << ","; |
| 586 | } |
| 587 | ss << it; |
| 588 | addComma = true; |
| 589 | } |
| 590 | ss << "]"; |
| 591 | |
| 592 | fn("DimMappings",ss.str()); |
| 593 | } |
| 594 | |
Teresa Charlin | 400c593 | 2021-06-04 10:29:47 +0100 | [diff] [blame] | 595 | void StringifyLayerParameters<ViewsDescriptor>::Serialize(ParameterStringifyFunction& fn, const ViewsDescriptor& desc) |
| 596 | { |
| 597 | uint32_t numViews = desc.GetNumViews(); |
| 598 | uint32_t numDims = desc.GetNumDimensions(); |
| 599 | for (uint32_t view = 0; view < numViews; ++view) { |
| 600 | std::stringstream key; |
| 601 | key << "ViewSizes#" << view; |
| 602 | std::stringstream value; |
| 603 | value << "["; |
| 604 | auto viewData = desc.GetViewSizes(view); |
| 605 | for (uint32_t dim = 0; dim < numDims; ++dim) |
| 606 | { |
| 607 | if (dim > 0) |
| 608 | { |
| 609 | value << ","; |
| 610 | } |
| 611 | value << viewData[dim]; |
| 612 | } |
| 613 | value << "]"; |
| 614 | fn(key.str(), value.str()); |
| 615 | } |
| 616 | StringifyLayerParameters<OriginsDescriptor>::Serialize(fn, desc.GetOrigins()); |
| 617 | } |
| 618 | |
Teresa Charlin | 190a39a | 2020-01-23 11:44:24 +0000 | [diff] [blame] | 619 | } // namespace armnn |