Saoirse Stewart | 3166c3e | 2019-02-18 15:24:53 +0000 | [diff] [blame^] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #include "SerializerUtils.hpp" |
| 7 | |
| 8 | namespace armnnSerializer |
| 9 | { |
| 10 | |
| 11 | using namespace armnn; |
| 12 | namespace serializer = armnn::armnnSerializer; |
| 13 | |
| 14 | serializer::DataType GetFlatBufferDataType(DataType dataType) |
| 15 | { |
| 16 | switch (dataType) |
| 17 | { |
| 18 | case DataType::Float32: |
| 19 | return serializer::DataType::DataType_Float32; |
| 20 | case DataType::Float16: |
| 21 | return serializer::DataType::DataType_Float16; |
| 22 | case DataType::Signed32: |
| 23 | return serializer::DataType::DataType_Signed32; |
| 24 | case DataType::QuantisedAsymm8: |
| 25 | return serializer::DataType::DataType_QuantisedAsymm8; |
| 26 | case DataType::Boolean: |
| 27 | return serializer::DataType::DataType_Boolean; |
| 28 | default: |
| 29 | return serializer::DataType::DataType_Float16; |
| 30 | } |
| 31 | } |
| 32 | |
| 33 | serializer::DataLayout GetFlatBufferDataLayout(DataLayout dataLayout) |
| 34 | { |
| 35 | switch (dataLayout) |
| 36 | { |
| 37 | case DataLayout::NHWC: |
| 38 | return serializer::DataLayout::DataLayout_NHWC; |
| 39 | case DataLayout::NCHW: |
| 40 | default: |
| 41 | return serializer::DataLayout::DataLayout_NCHW; |
| 42 | } |
| 43 | } |
| 44 | |
| 45 | serializer::PoolingAlgorithm GetFlatBufferPoolingAlgorithm(PoolingAlgorithm poolingAlgorithm) |
| 46 | { |
| 47 | switch (poolingAlgorithm) |
| 48 | { |
| 49 | case PoolingAlgorithm::Average: |
| 50 | return serializer::PoolingAlgorithm::PoolingAlgorithm_Average; |
| 51 | case PoolingAlgorithm::L2: |
| 52 | return serializer::PoolingAlgorithm::PoolingAlgorithm_L2; |
| 53 | case PoolingAlgorithm::Max: |
| 54 | default: |
| 55 | return serializer::PoolingAlgorithm::PoolingAlgorithm_Max; |
| 56 | } |
| 57 | } |
| 58 | |
| 59 | serializer::OutputShapeRounding GetFlatBufferOutputShapeRounding(OutputShapeRounding outputShapeRounding) |
| 60 | { |
| 61 | switch (outputShapeRounding) |
| 62 | { |
| 63 | case OutputShapeRounding::Ceiling: |
| 64 | return serializer::OutputShapeRounding::OutputShapeRounding_Ceiling; |
| 65 | case OutputShapeRounding::Floor: |
| 66 | default: |
| 67 | return serializer::OutputShapeRounding::OutputShapeRounding_Floor; |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | serializer::PaddingMethod GetFlatBufferPaddingMethod(PaddingMethod paddingMethod) |
| 72 | { |
| 73 | switch (paddingMethod) |
| 74 | { |
| 75 | case PaddingMethod::IgnoreValue: |
| 76 | return serializer::PaddingMethod::PaddingMethod_IgnoreValue; |
| 77 | case PaddingMethod::Exclude: |
| 78 | default: |
| 79 | return serializer::PaddingMethod::PaddingMethod_Exclude; |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | } // namespace armnnSerializer |