Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 1 | // |
Finn Williams | 2605b23 | 2020-06-10 15:53:46 +0100 | [diff] [blame] | 2 | // Copyright © 2017 Arm Ltd and Contributors. All rights reserved. |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 8 | #include <armnn/INetwork.hpp> |
| 9 | #include <armnnDeserializer/IDeserializer.hpp> |
Matthew Bentham | 268509a | 2019-02-25 13:58:24 +0000 | [diff] [blame] | 10 | #include <ArmnnSchema_generated.h> |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 11 | |
Nattapat Chaimanowong | d469faf | 2019-03-04 17:10:40 +0000 | [diff] [blame] | 12 | #include <unordered_map> |
| 13 | |
Derek Lamberti | 0028d1b | 2019-02-20 13:57:42 +0000 | [diff] [blame] | 14 | namespace armnnDeserializer |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 15 | { |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 16 | |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 17 | // Shorthands for deserializer types |
| 18 | using ConstTensorRawPtr = const armnnSerializer::ConstTensor *; |
| 19 | using GraphPtr = const armnnSerializer::SerializedGraph *; |
| 20 | using TensorRawPtr = const armnnSerializer::TensorInfo *; |
Tamas Nyiri | d998a1c | 2021-11-05 14:55:33 +0000 | [diff] [blame] | 21 | using Pooling2dDescriptor = const armnnSerializer::Pooling2dDescriptor *; |
| 22 | using Pooling3dDescriptor = const armnnSerializer::Pooling3dDescriptor *; |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 23 | using NormalizationDescriptorPtr = const armnnSerializer::NormalizationDescriptor *; |
| 24 | using LstmDescriptorPtr = const armnnSerializer::LstmDescriptor *; |
| 25 | using LstmInputParamsPtr = const armnnSerializer::LstmInputParams *; |
| 26 | using QLstmDescriptorPtr = const armnnSerializer::QLstmDescriptor *; |
| 27 | using QunatizedLstmInputParamsPtr = const armnnSerializer::QuantizedLstmInputParams *; |
| 28 | using TensorRawPtrVector = std::vector<TensorRawPtr>; |
| 29 | using LayerRawPtr = const armnnSerializer::LayerBase *; |
| 30 | using LayerBaseRawPtr = const armnnSerializer::LayerBase *; |
| 31 | using LayerBaseRawPtrVector = std::vector<LayerBaseRawPtr>; |
Narumol Prangnawarat | a0162e1 | 2021-07-23 14:47:49 +0100 | [diff] [blame] | 32 | using UnidirectionalSequenceLstmDescriptorPtr = const armnnSerializer::UnidirectionalSequenceLstmDescriptor *; |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 33 | |
| 34 | class IDeserializer::DeserializerImpl |
| 35 | { |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 36 | public: |
| 37 | |
Derek Lamberti | 2b183fb | 2019-02-18 16:36:57 +0000 | [diff] [blame] | 38 | /// Create an input network from binary file contents |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 39 | armnn::INetworkPtr CreateNetworkFromBinary(const std::vector<uint8_t>& binaryContent); |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 40 | |
Derek Lamberti | 2b183fb | 2019-02-18 16:36:57 +0000 | [diff] [blame] | 41 | /// Create an input network from a binary input stream |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 42 | armnn::INetworkPtr CreateNetworkFromBinary(std::istream& binaryContent); |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 43 | |
| 44 | /// Retrieve binding info (layer id and tensor info) for the network input identified by the given layer name |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 45 | BindingPointInfo GetNetworkInputBindingInfo(unsigned int layerId, const std::string& name) const; |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 46 | |
| 47 | /// Retrieve binding info (layer id and tensor info) for the network output identified by the given layer name |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 48 | BindingPointInfo GetNetworkOutputBindingInfo(unsigned int layerId, const std::string& name) const; |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 49 | |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 50 | DeserializerImpl(); |
| 51 | ~DeserializerImpl() = default; |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 52 | |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 53 | // No copying allowed until it is wanted and properly implemented |
| 54 | DeserializerImpl(const DeserializerImpl&) = delete; |
| 55 | DeserializerImpl& operator=(const DeserializerImpl&) = delete; |
| 56 | |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 57 | // testable helpers |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 58 | static GraphPtr LoadGraphFromBinary(const uint8_t* binaryContent, size_t len); |
| 59 | static TensorRawPtrVector GetInputs(const GraphPtr& graph, unsigned int layerIndex); |
| 60 | static TensorRawPtrVector GetOutputs(const GraphPtr& graph, unsigned int layerIndex); |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 61 | static LayerBaseRawPtr GetBaseLayer(const GraphPtr& graphPtr, unsigned int layerIndex); |
| 62 | static int32_t GetBindingLayerInfo(const GraphPtr& graphPtr, unsigned int layerIndex); |
Éanna Ó Catháin | 633f859 | 2019-02-25 16:26:29 +0000 | [diff] [blame] | 63 | static std::string GetLayerName(const GraphPtr& graph, unsigned int index); |
Tamas Nyiri | d998a1c | 2021-11-05 14:55:33 +0000 | [diff] [blame] | 64 | static armnn::Pooling2dDescriptor GetPooling2dDescriptor(Pooling2dDescriptor pooling2dDescriptor, |
| 65 | unsigned int layerIndex); |
| 66 | static armnn::Pooling3dDescriptor GetPooling3dDescriptor(Pooling3dDescriptor pooling3dDescriptor, |
Nina Drozd | 5772878 | 2019-02-27 10:53:27 +0000 | [diff] [blame] | 67 | unsigned int layerIndex); |
| 68 | static armnn::NormalizationDescriptor GetNormalizationDescriptor( |
| 69 | NormalizationDescriptorPtr normalizationDescriptor, unsigned int layerIndex); |
Jim Flynn | 11af375 | 2019-03-19 17:22:29 +0000 | [diff] [blame] | 70 | static armnn::LstmDescriptor GetLstmDescriptor(LstmDescriptorPtr lstmDescriptor); |
| 71 | static armnn::LstmInputParams GetLstmInputParams(LstmDescriptorPtr lstmDescriptor, |
| 72 | LstmInputParamsPtr lstmInputParams); |
James Conroy | 8d33318 | 2020-05-13 10:27:58 +0100 | [diff] [blame] | 73 | static armnn::QLstmDescriptor GetQLstmDescriptor(QLstmDescriptorPtr qLstmDescriptorPtr); |
Narumol Prangnawarat | a0162e1 | 2021-07-23 14:47:49 +0100 | [diff] [blame] | 74 | static armnn::UnidirectionalSequenceLstmDescriptor GetUnidirectionalSequenceLstmDescriptor( |
| 75 | UnidirectionalSequenceLstmDescriptorPtr descriptor); |
Saoirse Stewart | 263829c | 2019-02-19 15:54:14 +0000 | [diff] [blame] | 76 | static armnn::TensorInfo OutputShapeOfReshape(const armnn::TensorInfo & inputTensorInfo, |
| 77 | const std::vector<uint32_t> & targetDimsIn); |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 78 | |
| 79 | private: |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 80 | /// Create the network from an already loaded flatbuffers graph |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 81 | armnn::INetworkPtr CreateNetworkFromGraph(GraphPtr graph); |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 82 | |
| 83 | // signature for the parser functions |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 84 | using LayerParsingFunction = void(DeserializerImpl::*)(GraphPtr graph, unsigned int layerIndex); |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 85 | |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 86 | void ParseUnsupportedLayer(GraphPtr graph, unsigned int layerIndex); |
FinnWilliamsArm | 4ffcc8f | 2019-09-05 14:34:20 +0100 | [diff] [blame] | 87 | void ParseAbs(GraphPtr graph, unsigned int layerIndex); |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 88 | void ParseActivation(GraphPtr graph, unsigned int layerIndex); |
| 89 | void ParseAdd(GraphPtr graph, unsigned int layerIndex); |
Narumol Prangnawarat | 0cfcf23 | 2019-09-09 17:16:24 +0100 | [diff] [blame] | 90 | void ParseArgMinMax(GraphPtr graph, unsigned int layerIndex); |
Nattapat Chaimanowong | 6b4ed98 | 2019-02-26 17:24:13 +0000 | [diff] [blame] | 91 | void ParseBatchToSpaceNd(GraphPtr graph, unsigned int layerIndex); |
ruoyan01 | 8e7fa23 | 2019-02-28 15:09:07 +0000 | [diff] [blame] | 92 | void ParseBatchNormalization(GraphPtr graph, unsigned int layerIndex); |
mathad01 | b392e98 | 2021-04-07 12:07:30 +0100 | [diff] [blame] | 93 | void ParseCast(GraphPtr graph, unsigned int layerIndex); |
Simon Obute | 51f6777 | 2021-09-03 15:50:13 +0100 | [diff] [blame] | 94 | void ParseChannelShuffle(GraphPtr graph, unsigned int layerIndex); |
Aron Virginas-Tar | e80ebd1 | 2019-10-17 16:11:54 +0100 | [diff] [blame] | 95 | void ParseComparison(GraphPtr graph, unsigned int layerIndex); |
Jim Flynn | 906f946 | 2019-05-10 13:55:21 +0100 | [diff] [blame] | 96 | void ParseConcat(GraphPtr graph, unsigned int layerIndex); |
Conor Kennedy | 7627788 | 2019-02-26 08:29:54 +0000 | [diff] [blame] | 97 | void ParseConstant(GraphPtr graph, unsigned int layerIndex); |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 98 | void ParseConvolution2d(GraphPtr graph, unsigned int layerIndex); |
Matthew Sloyan | b63a311 | 2021-09-08 13:05:51 +0100 | [diff] [blame] | 99 | void ParseConvolution3d(GraphPtr graph, unsigned int layerIndex); |
Aron Virginas-Tar | da9d2d3 | 2019-09-20 10:42:02 +0100 | [diff] [blame] | 100 | void ParseDepthToSpace(GraphPtr graph, unsigned int layerIndex); |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 101 | void ParseDepthwiseConvolution2d(GraphPtr graph, unsigned int layerIndex); |
Nattapat Chaimanowong | e4294fd | 2019-03-28 09:56:53 +0000 | [diff] [blame] | 102 | void ParseDequantize(GraphPtr graph, unsigned int layerIndex); |
Nattapat Chaimanowong | 3e14a9d | 2019-03-18 12:37:06 +0000 | [diff] [blame] | 103 | void ParseDetectionPostProcess(GraphPtr graph, unsigned int layerIndex); |
Éanna Ó Catháin | 5888589 | 2019-02-27 16:16:39 +0000 | [diff] [blame] | 104 | void ParseDivision(GraphPtr graph, unsigned int layerIndex); |
josh minor | 4a3c610 | 2020-01-06 16:40:46 -0600 | [diff] [blame] | 105 | void ParseElementwiseUnary(GraphPtr graph, unsigned int layerIndex); |
Nattapat Chaimanowong | 235cea5 | 2019-02-28 16:27:30 +0000 | [diff] [blame] | 106 | void ParseEqual(GraphPtr graph, unsigned int layerIndex); |
Keith Davis | 300ad56 | 2020-06-04 16:34:23 +0100 | [diff] [blame] | 107 | void ParseFill(GraphPtr graph, unsigned int layerIndex); |
Finn Williams | dd2ba7e | 2019-03-01 11:51:52 +0000 | [diff] [blame] | 108 | void ParseFloor(GraphPtr graph, unsigned int layerIndex); |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 109 | void ParseFullyConnected(GraphPtr graph, unsigned int layerIndex); |
Saoirse Stewart | a1ed73a | 2019-03-04 13:40:12 +0000 | [diff] [blame] | 110 | void ParseGather(GraphPtr graph, unsigned int layerIndex); |
Teresa Charlin | 6966bfa | 2022-04-25 17:14:50 +0100 | [diff] [blame] | 111 | void ParseGatherNd(GraphPtr graph, unsigned int layerIndex); |
Conor Kennedy | 79ffdf5 | 2019-03-01 14:24:54 +0000 | [diff] [blame] | 112 | void ParseGreater(GraphPtr graph, unsigned int layerIndex); |
Aron Virginas-Tar | 781ced9 | 2019-10-03 11:15:39 +0100 | [diff] [blame] | 113 | void ParseInstanceNormalization(GraphPtr graph, unsigned int layerIndex); |
Narumol Prangnawarat | 495701f | 2019-03-07 17:31:34 +0000 | [diff] [blame] | 114 | void ParseL2Normalization(GraphPtr graph, unsigned int layerIndex); |
James Conroy | aba90cd | 2020-11-06 16:28:18 +0000 | [diff] [blame] | 115 | void ParseLogicalBinary(GraphPtr graph, unsigned int layerIndex); |
Sadik Armagan | 2625785 | 2019-10-14 13:00:47 +0100 | [diff] [blame] | 116 | void ParseLogSoftmax(GraphPtr graph, unsigned int layerIndex); |
Aron Virginas-Tar | 377351e | 2019-02-27 14:42:31 +0000 | [diff] [blame] | 117 | void ParseMaximum(GraphPtr graph, unsigned int layerIndex); |
Sadik Armagan | ac97c8c | 2019-03-04 17:44:21 +0000 | [diff] [blame] | 118 | void ParseMean(GraphPtr graph, unsigned int layerIndex); |
| 119 | void ParseMinimum(GraphPtr graph, unsigned int layerIndex); |
Nattapat Chaimanowong | 1f88630 | 2019-04-05 13:37:19 +0100 | [diff] [blame] | 120 | void ParseMerge(GraphPtr graph, unsigned int layerIndex); |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 121 | void ParseMultiplication(GraphPtr graph, unsigned int layerIndex); |
Nina Drozd | 5772878 | 2019-02-27 10:53:27 +0000 | [diff] [blame] | 122 | void ParseNormalization(GraphPtr graph, unsigned int layerIndex); |
Jim Flynn | 11af375 | 2019-03-19 17:22:29 +0000 | [diff] [blame] | 123 | void ParseLstm(GraphPtr graph, unsigned int layerIndex); |
Jan Eilers | 5b01a89 | 2019-07-23 09:47:43 +0100 | [diff] [blame] | 124 | void ParseQuantizedLstm(GraphPtr graph, unsigned int layerIndex); |
Nattapat Chaimanowong | ebb0f9c | 2019-03-01 12:14:06 +0000 | [diff] [blame] | 125 | void ParsePad(GraphPtr graph, unsigned int layerIndex); |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 126 | void ParsePermute(GraphPtr graph, unsigned int layerIndex); |
| 127 | void ParsePooling2d(GraphPtr graph, unsigned int layerIndex); |
Tamas Nyiri | d998a1c | 2021-11-05 14:55:33 +0000 | [diff] [blame] | 128 | void ParsePooling3d(GraphPtr graph, unsigned int layerIndex); |
Ellen Norris-Thompson | 5198247 | 2019-06-19 11:46:21 +0100 | [diff] [blame] | 129 | void ParsePrelu(GraphPtr graph, unsigned int layerIndex); |
James Conroy | 8d33318 | 2020-05-13 10:27:58 +0100 | [diff] [blame] | 130 | void ParseQLstm(GraphPtr graph, unsigned int layerIndex); |
Derek Lamberti | 87acb27 | 2019-03-27 16:51:31 +0000 | [diff] [blame] | 131 | void ParseQuantize(GraphPtr graph, unsigned int layerIndex); |
Finn Williams | 2605b23 | 2020-06-10 15:53:46 +0100 | [diff] [blame] | 132 | void ParseRank(GraphPtr graph, unsigned int layerIndex); |
Sadik Armagan | 0c3ea5b | 2021-02-03 09:29:30 +0000 | [diff] [blame] | 133 | void ParseReduce(GraphPtr graph, unsigned int layerIndex); |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 134 | void ParseReshape(GraphPtr graph, unsigned int layerIndex); |
FinnWilliamsArm | 6fb339a | 2019-06-28 15:07:10 +0100 | [diff] [blame] | 135 | void ParseResize(GraphPtr graph, unsigned int layerIndex); |
Nattapat Chaimanowong | 6522cdc | 2019-03-01 16:14:13 +0000 | [diff] [blame] | 136 | void ParseResizeBilinear(GraphPtr graph, unsigned int layerIndex); |
Sadik Armagan | 8b42a38 | 2019-03-01 14:24:49 +0000 | [diff] [blame] | 137 | void ParseRsqrt(GraphPtr graph, unsigned int layerIndex); |
Keith Davis | 3ae3f97 | 2021-05-21 16:33:48 +0100 | [diff] [blame] | 138 | void ParseShape(GraphPtr graph, unsigned int layerIndex); |
Aron Virginas-Tar | 2fda80b | 2019-09-18 13:36:52 +0100 | [diff] [blame] | 139 | void ParseSlice(GraphPtr graph, unsigned int layerIndex); |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 140 | void ParseSoftmax(GraphPtr graph, unsigned int layerIndex); |
Nattapat Chaimanowong | 4528699 | 2019-02-26 15:53:02 +0000 | [diff] [blame] | 141 | void ParseSpaceToBatchNd(GraphPtr graph, unsigned int layerIndex); |
Aron Virginas-Tar | aa06714 | 2019-06-11 16:01:44 +0100 | [diff] [blame] | 142 | void ParseSpaceToDepth(GraphPtr graph, unsigned int layerIndex); |
Jim Flynn | 18ce338 | 2019-03-08 11:08:30 +0000 | [diff] [blame] | 143 | void ParseSplitter(GraphPtr graph, unsigned int layerIndex); |
Matthew Jackson | b5433ee | 2019-07-11 15:54:20 +0100 | [diff] [blame] | 144 | void ParseStack(GraphPtr graph, unsigned int layerIndex); |
Aron Virginas-Tar | 85121a2 | 2019-10-23 10:41:35 +0100 | [diff] [blame] | 145 | void ParseStandIn(GraphPtr graph, unsigned int layerIndex); |
Nattapat Chaimanowong | b348521 | 2019-03-04 12:35:39 +0000 | [diff] [blame] | 146 | void ParseStridedSlice(GraphPtr graph, unsigned int layerIndex); |
Conor Kennedy | da1f975 | 2019-03-01 14:37:12 +0000 | [diff] [blame] | 147 | void ParseSubtraction(GraphPtr graph, unsigned int layerIndex); |
Sadik Armagan | eff363d | 2019-04-05 15:25:46 +0100 | [diff] [blame] | 148 | void ParseSwitch(GraphPtr graph, unsigned int layerIndex); |
Mike Kelly | c9ea45a | 2020-02-28 18:11:58 +0000 | [diff] [blame] | 149 | void ParseTranspose(GraphPtr graph, unsigned int layerIndex); |
Aron Virginas-Tar | cb54930 | 2019-06-21 13:53:38 +0100 | [diff] [blame] | 150 | void ParseTransposeConvolution2d(GraphPtr graph, unsigned int layerIndex); |
Narumol Prangnawarat | a0162e1 | 2021-07-23 14:47:49 +0100 | [diff] [blame] | 151 | void ParseUnidirectionalSequenceLstm(GraphPtr graph, unsigned int layerIndex); |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 152 | |
Matthew Sloyan | 81beae3 | 2021-07-13 19:46:11 +0100 | [diff] [blame] | 153 | void RegisterInputSlots(GraphPtr graph, |
| 154 | uint32_t layerIndex, |
| 155 | armnn::IConnectableLayer* layer, |
| 156 | std::vector<unsigned int> ignoreSlots = {}); |
| 157 | void RegisterOutputSlots(GraphPtr graph, |
| 158 | uint32_t layerIndex, |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 159 | armnn::IConnectableLayer* layer); |
Nattapat Chaimanowong | af000a9 | 2019-05-16 16:32:35 +0100 | [diff] [blame] | 160 | |
| 161 | // NOTE index here must be from flatbuffer object index property |
| 162 | void RegisterOutputSlotOfConnection(uint32_t sourceLayerIndex, uint32_t outputSlotIndex, armnn::IOutputSlot* slot); |
| 163 | void RegisterInputSlotOfConnection(uint32_t sourceLayerIndex, uint32_t outputSlotIndex, armnn::IInputSlot* slot); |
| 164 | |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 165 | void ResetParser(); |
| 166 | |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 167 | void SetupInputLayers(GraphPtr graphPtr); |
| 168 | void SetupOutputLayers(GraphPtr graphPtr); |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 169 | |
Tee Jung | aa920c5 | 2019-11-05 10:48:25 +0000 | [diff] [blame] | 170 | /// Helper to get the index of the layer in the flatbuffer vector from its bindingId property |
| 171 | unsigned int GetInputLayerInVector(GraphPtr graph, int targetId); |
| 172 | unsigned int GetOutputLayerInVector(GraphPtr graph, int targetId); |
| 173 | |
Nattapat Chaimanowong | af000a9 | 2019-05-16 16:32:35 +0100 | [diff] [blame] | 174 | /// Helper to get the index of the layer in the flatbuffer vector from its index property |
| 175 | unsigned int GetLayerIndexInVector(GraphPtr graph, unsigned int index); |
| 176 | |
Tee Jung | aa920c5 | 2019-11-05 10:48:25 +0000 | [diff] [blame] | 177 | struct FeatureVersions |
| 178 | { |
| 179 | // Default values to zero for backward compatibility |
| 180 | unsigned int m_BindingIdScheme = 0; |
Jan Eilers | 53ef795 | 2021-06-02 12:01:25 +0100 | [diff] [blame] | 181 | |
| 182 | // Default values to zero for backward compatibility |
| 183 | unsigned int m_WeightsLayoutScheme = 0; |
Matthew Sloyan | 81beae3 | 2021-07-13 19:46:11 +0100 | [diff] [blame] | 184 | |
| 185 | // Default values to zero for backward compatibility |
| 186 | unsigned int m_ConstTensorsAsInputs = 0; |
Tee Jung | aa920c5 | 2019-11-05 10:48:25 +0000 | [diff] [blame] | 187 | }; |
| 188 | |
| 189 | FeatureVersions GetFeatureVersions(GraphPtr graph); |
| 190 | |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 191 | /// The network we're building. Gets cleared after it is passed to the user |
| 192 | armnn::INetworkPtr m_Network; |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 193 | std::vector<LayerParsingFunction> m_ParserFunctions; |
| 194 | |
Derek Lamberti | 8ddae33 | 2019-02-21 16:29:43 +0000 | [diff] [blame] | 195 | using NameToBindingInfo = std::pair<std::string, BindingPointInfo >; |
| 196 | std::vector<NameToBindingInfo> m_InputBindings; |
| 197 | std::vector<NameToBindingInfo> m_OutputBindings; |
| 198 | |
Nattapat Chaimanowong | af000a9 | 2019-05-16 16:32:35 +0100 | [diff] [blame] | 199 | /// This struct describe connections for each layer |
| 200 | struct Connections |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 201 | { |
Nattapat Chaimanowong | af000a9 | 2019-05-16 16:32:35 +0100 | [diff] [blame] | 202 | // Maps output slot index (property in flatbuffer object) to IOutputSlot pointer |
| 203 | std::unordered_map<unsigned int, armnn::IOutputSlot*> outputSlots; |
| 204 | |
| 205 | // Maps output slot index to IInputSlot pointer the output slot should be connected to |
Nattapat Chaimanowong | d469faf | 2019-03-04 17:10:40 +0000 | [diff] [blame] | 206 | std::unordered_map<unsigned int, std::vector<armnn::IInputSlot*>> inputSlots; |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 207 | }; |
Nattapat Chaimanowong | d469faf | 2019-03-04 17:10:40 +0000 | [diff] [blame] | 208 | |
Nattapat Chaimanowong | af000a9 | 2019-05-16 16:32:35 +0100 | [diff] [blame] | 209 | /// Maps layer index (index property in flatbuffer object) to Connections for each layer |
| 210 | std::unordered_map<unsigned int, Connections> m_GraphConnections; |
Kevin May | 43a799c | 2019-02-08 16:31:42 +0000 | [diff] [blame] | 211 | }; |
| 212 | |
Finn Williams | 85d3671 | 2021-01-26 22:30:06 +0000 | [diff] [blame] | 213 | } // namespace armnnDeserializer |