telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2017 Arm Ltd. All rights reserved. |
David Beck | ecb56cd | 2018-09-05 12:52:57 +0100 | [diff] [blame^] | 3 | // SPDX-License-Identifier: MIT |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 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 | |
| 12 | #include <memory> |
| 13 | #include <map> |
| 14 | #include <vector> |
| 15 | |
| 16 | namespace armnnTfLiteParser |
| 17 | { |
| 18 | |
| 19 | // TODO: revise this: do we really need this for every parser??? |
| 20 | using BindingPointInfo = std::pair<armnn::LayerBindingId, armnn::TensorInfo>; |
| 21 | |
| 22 | class ITfLiteParser; |
| 23 | using ITfLiteParserPtr = std::unique_ptr<ITfLiteParser, void(*)(ITfLiteParser* parser)>; |
| 24 | |
| 25 | class ITfLiteParser |
| 26 | { |
| 27 | public: |
| 28 | static ITfLiteParser* CreateRaw(); |
| 29 | static ITfLiteParserPtr Create(); |
| 30 | static void Destroy(ITfLiteParser* parser); |
| 31 | |
| 32 | /// Create the network from a flatbuffers binary file on disk |
| 33 | virtual armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile) = 0; |
| 34 | |
| 35 | /// Create the network from a flatbuffers binary |
| 36 | virtual armnn::INetworkPtr CreateNetworkFromBinary(const std::vector<uint8_t> & binaryContent) = 0; |
| 37 | |
| 38 | /// Retrieve binding info (layer id and tensor info) for the network input identified by |
| 39 | /// the given layer name and subgraph id |
| 40 | virtual BindingPointInfo GetNetworkInputBindingInfo(size_t subgraphId, |
| 41 | const std::string& name) const = 0; |
| 42 | |
| 43 | /// Retrieve binding info (layer id and tensor info) for the network output identified by |
| 44 | /// the given layer name and subgraph id |
| 45 | virtual BindingPointInfo GetNetworkOutputBindingInfo(size_t subgraphId, |
| 46 | const std::string& name) const = 0; |
| 47 | |
| 48 | /// Return the number of subgraphs in the parsed model |
| 49 | virtual size_t GetSubgraphCount() const = 0; |
| 50 | |
| 51 | /// Return the input tensor names for a given subgraph |
| 52 | virtual std::vector<std::string> GetSubgraphInputTensorNames(size_t subgraphId) const = 0; |
| 53 | |
| 54 | /// Return the output tensor names for a given subgraph |
| 55 | virtual std::vector<std::string> GetSubgraphOutputTensorNames(size_t subgraphId) const = 0; |
| 56 | |
| 57 | protected: |
| 58 | virtual ~ITfLiteParser() {}; |
| 59 | }; |
| 60 | |
| 61 | } |