ArmNN
 24.02
ITfLiteParser.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
7 #include "armnn/Types.hpp"
8 #include "armnn/NetworkFwd.hpp"
9 #include "armnn/Tensor.hpp"
10 #include "armnn/INetwork.hpp"
11 #include "armnn/Optional.hpp"
12 
13 #include <memory>
14 #include <map>
15 #include <vector>
16 
18 {
19 
21 
22 class TfLiteParserImpl;
23 class ITfLiteParser;
24 using ITfLiteParserPtr = std::unique_ptr<ITfLiteParser, void(*)(ITfLiteParser* parser)>;
25 
27 {
28 public:
30  {
32  : m_AllowExpandedDims(false),
34  m_InferAndValidate(false) {}
35 
39  };
40 
43  static void Destroy(ITfLiteParser* parser);
44 
45  /// Create the network from a flatbuffers binary file on disk
46  armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile);
47 
48  /// Create the network from a flatbuffers binary
49  armnn::INetworkPtr CreateNetworkFromBinary(const std::vector<uint8_t> & binaryContent);
50 
51  /// Retrieve binding info (layer id and tensor info) for the network input identified by
52  /// the given layer name and subgraph id
54  const std::string& name) const;
55 
56  /// Retrieve binding info (layer id and tensor info) for the network output identified by
57  /// the given layer name and subgraph id
59  const std::string& name) const;
60 
61  /// Return the number of subgraphs in the parsed model
62  size_t GetSubgraphCount() const;
63 
64  /// Return the input tensor names for a given subgraph
65  std::vector<std::string> GetSubgraphInputTensorNames(size_t subgraphId) const;
66 
67  /// Return the output tensor names for a given subgraph
68  std::vector<std::string> GetSubgraphOutputTensorNames(size_t subgraphId) const;
69 
70 private:
72  ~ITfLiteParser();
73 
74  std::unique_ptr<TfLiteParserImpl> pTfLiteParserImpl;
75 };
76 
77 }
armnn::INetworkPtr
std::unique_ptr< INetwork, void(*)(INetwork *network)> INetworkPtr
Definition: INetwork.hpp:339
armnnTfLiteParser::ITfLiteParser::GetSubgraphOutputTensorNames
std::vector< std::string > GetSubgraphOutputTensorNames(size_t subgraphId) const
Return the output tensor names for a given subgraph.
Definition: TfLiteParser.cpp:105
armnn::BindingPointInfo
std::pair< armnn::LayerBindingId, armnn::TensorInfo > BindingPointInfo
Definition: Tensor.hpp:276
armnnTfLiteParser::ITfLiteParser::TfLiteParserOptions::m_AllowExpandedDims
bool m_AllowExpandedDims
Definition: ITfLiteParser.hpp:36
armnn::Optional
Definition: Optional.hpp:270
armnnTfLiteParser::ITfLiteParser::GetNetworkInputBindingInfo
BindingPointInfo GetNetworkInputBindingInfo(size_t subgraphId, const std::string &name) const
Retrieve binding info (layer id and tensor info) for the network input identified by the given layer ...
Definition: TfLiteParser.cpp:83
armnnTfLiteParser::ITfLiteParser::Create
static ITfLiteParserPtr Create(const armnn::Optional< TfLiteParserOptions > &options=armnn::EmptyOptional())
Definition: TfLiteParser.cpp:63
armnnTfLiteParser::ITfLiteParser::CreateRaw
static ITfLiteParser * CreateRaw(const armnn::Optional< TfLiteParserOptions > &options=armnn::EmptyOptional())
Definition: TfLiteParser.cpp:58
armnnTfLiteParser::ITfLiteParser::GetSubgraphInputTensorNames
std::vector< std::string > GetSubgraphInputTensorNames(size_t subgraphId) const
Return the input tensor names for a given subgraph.
Definition: TfLiteParser.cpp:100
Optional.hpp
INetwork.hpp
armnnTfLiteParser::BindingPointInfo
armnn::BindingPointInfo BindingPointInfo
Definition: ITfLiteParser.hpp:20
armnnTfLiteParser::ITfLiteParser::GetSubgraphCount
size_t GetSubgraphCount() const
Return the number of subgraphs in the parsed model.
Definition: TfLiteParser.cpp:95
armnnTfLiteParser::ITfLiteParser::TfLiteParserOptions::m_InferAndValidate
bool m_InferAndValidate
Definition: ITfLiteParser.hpp:38
armnn::EmptyOptional
EmptyOptional is used to initialize the Optional class in case we want to have default value for an O...
Definition: Optional.hpp:32
armnnTfLiteParser::ITfLiteParser::Destroy
static void Destroy(ITfLiteParser *parser)
Definition: TfLiteParser.cpp:68
armnnTfLiteParser::ITfLiteParserPtr
std::unique_ptr< ITfLiteParser, void(*)(ITfLiteParser *parser)> ITfLiteParserPtr
Definition: ITfLiteParser.hpp:24
armnnTfLiteParser::ITfLiteParser::CreateNetworkFromBinaryFile
armnn::INetworkPtr CreateNetworkFromBinaryFile(const char *graphFile)
Create the network from a flatbuffers binary file on disk.
Definition: TfLiteParser.cpp:73
armnnTfLiteParser::ITfLiteParser::TfLiteParserOptions::m_StandInLayerForUnsupported
bool m_StandInLayerForUnsupported
Definition: ITfLiteParser.hpp:37
armnnTfLiteParser::ITfLiteParser::TfLiteParserOptions::TfLiteParserOptions
TfLiteParserOptions()
Definition: ITfLiteParser.hpp:31
armnnTfLiteParser::TfLiteParserImpl
Definition: TfLiteParser.hpp:26
armnnTfLiteParser::ITfLiteParser::TfLiteParserOptions
Definition: ITfLiteParser.hpp:29
Tensor.hpp
armnnTfLiteParser::ITfLiteParser::GetNetworkOutputBindingInfo
BindingPointInfo GetNetworkOutputBindingInfo(size_t subgraphId, const std::string &name) const
Retrieve binding info (layer id and tensor info) for the network output identified by the given layer...
Definition: TfLiteParser.cpp:89
Types.hpp
armnnTfLiteParser
Definition: ITfLiteParser.hpp:17
NetworkFwd.hpp
armnnTfLiteParser::ITfLiteParser::CreateNetworkFromBinary
armnn::INetworkPtr CreateNetworkFromBinary(const std::vector< uint8_t > &binaryContent)
Create the network from a flatbuffers binary.
Definition: TfLiteParser.cpp:78
armnnTfLiteParser::ITfLiteParser
Definition: ITfLiteParser.hpp:26