aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorKevin May <kevin.may@arm.com>2021-02-03 17:38:41 +0000
committerFrancis Murtagh <francis.murtagh@arm.com>2021-02-04 11:23:41 +0000
commit7d96b16acfdbdcef6739d59ba067a37c062aa03f (patch)
treebb0a93f9030e26568d6d7c44776993e433996c31 /include
parentd0bb8eafef2a93356e435ccc4029d487a2cde9e4 (diff)
downloadarmnn-7d96b16acfdbdcef6739d59ba067a37c062aa03f.tar.gz
IVGCVSW-5592 Implement Pimpl Idiom for Tf and TfLite Parsers
Signed-off-by: Kevin May <kevin.may@arm.com> Change-Id: I4a82aca4a2c47b3c598b91bc0075c09397be728a
Diffstat (limited to 'include')
-rw-r--r--include/armnnTfLiteParser/ITfLiteParser.hpp26
-rw-r--r--include/armnnTfParser/ITfParser.hpp37
2 files changed, 42 insertions, 21 deletions
diff --git a/include/armnnTfLiteParser/ITfLiteParser.hpp b/include/armnnTfLiteParser/ITfLiteParser.hpp
index a68b719a66..b286c1ee4c 100644
--- a/include/armnnTfLiteParser/ITfLiteParser.hpp
+++ b/include/armnnTfLiteParser/ITfLiteParser.hpp
@@ -19,6 +19,7 @@ namespace armnnTfLiteParser
using BindingPointInfo = armnn::BindingPointInfo;
+class TfLiteParserImpl;
class ITfLiteParser;
using ITfLiteParserPtr = std::unique_ptr<ITfLiteParser, void(*)(ITfLiteParser* parser)>;
@@ -40,32 +41,35 @@ public:
static void Destroy(ITfLiteParser* parser);
/// Create the network from a flatbuffers binary file on disk
- virtual armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile) = 0;
+ armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile);
/// Create the network from a flatbuffers binary
- virtual armnn::INetworkPtr CreateNetworkFromBinary(const std::vector<uint8_t> & binaryContent) = 0;
+ armnn::INetworkPtr CreateNetworkFromBinary(const std::vector<uint8_t> & binaryContent);
/// Retrieve binding info (layer id and tensor info) for the network input identified by
/// the given layer name and subgraph id
- virtual BindingPointInfo GetNetworkInputBindingInfo(size_t subgraphId,
- const std::string& name) const = 0;
+ BindingPointInfo GetNetworkInputBindingInfo(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 name and subgraph id
- virtual BindingPointInfo GetNetworkOutputBindingInfo(size_t subgraphId,
- const std::string& name) const = 0;
+ BindingPointInfo GetNetworkOutputBindingInfo(size_t subgraphId,
+ const std::string& name) const;
/// Return the number of subgraphs in the parsed model
- virtual size_t GetSubgraphCount() const = 0;
+ size_t GetSubgraphCount() const;
/// Return the input tensor names for a given subgraph
- virtual std::vector<std::string> GetSubgraphInputTensorNames(size_t subgraphId) const = 0;
+ std::vector<std::string> GetSubgraphInputTensorNames(size_t subgraphId) const;
/// Return the output tensor names for a given subgraph
- virtual std::vector<std::string> GetSubgraphOutputTensorNames(size_t subgraphId) const = 0;
+ std::vector<std::string> GetSubgraphOutputTensorNames(size_t subgraphId) const;
-protected:
- virtual ~ITfLiteParser() {};
+private:
+ ITfLiteParser(const armnn::Optional<TfLiteParserOptions>& options = armnn::EmptyOptional());
+ ~ITfLiteParser();
+
+ std::unique_ptr<TfLiteParserImpl> pTfLiteParserImpl;
};
}
diff --git a/include/armnnTfParser/ITfParser.hpp b/include/armnnTfParser/ITfParser.hpp
index b0ffc0d379..91e4cb39bf 100644
--- a/include/armnnTfParser/ITfParser.hpp
+++ b/include/armnnTfParser/ITfParser.hpp
@@ -30,31 +30,48 @@ public:
static void Destroy(ITfParser* parser);
/// Create the network from a protobuf text file on the disk.
- virtual armnn::INetworkPtr CreateNetworkFromTextFile(
+ armnn::INetworkPtr CreateNetworkFromTextFile(
const char* graphFile,
const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs) = 0;
+ const std::vector<std::string>& requestedOutputs);
/// Create the network from a protobuf binary file on the disk.
- virtual armnn::INetworkPtr CreateNetworkFromBinaryFile(
+ armnn::INetworkPtr CreateNetworkFromBinaryFile(
const char* graphFile,
const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs) = 0;
+ const std::vector<std::string>& requestedOutputs);
/// Create the network directly from protobuf text in a string. Useful for debugging/testing.
- virtual armnn::INetworkPtr CreateNetworkFromString(
+ armnn::INetworkPtr CreateNetworkFromString(
const char* protoText,
const std::map<std::string, armnn::TensorShape>& inputShapes,
- const std::vector<std::string>& requestedOutputs) = 0;
+ const std::vector<std::string>& requestedOutputs);
/// Retrieve binding info (layer id and tensor info) for the network input identified by the given layer name.
- virtual BindingPointInfo GetNetworkInputBindingInfo(const std::string& name) const = 0;
+ BindingPointInfo GetNetworkInputBindingInfo(const std::string& name) const;
/// Retrieve binding info (layer id and tensor info) for the network output identified by the given layer name.
- virtual BindingPointInfo GetNetworkOutputBindingInfo(const std::string& name) const = 0;
+ BindingPointInfo GetNetworkOutputBindingInfo(const std::string& name) const;
-protected:
- virtual ~ITfParser() {};
+private:
+ template <typename T>
+ friend class ParsedConstTfOperation;
+ friend class ParsedMatMulTfOperation;
+ friend class ParsedMulTfOperation;
+ friend class ParsedTfOperation;
+ friend class SingleLayerParsedTfOperation;
+ friend class DeferredSingleLayerParsedTfOperation;
+ friend class ParsedIdentityTfOperation;
+
+ template <template<typename> class OperatorType, typename T>
+ friend struct MakeTfOperation;
+
+
+ ITfParser();
+ ~ITfParser();
+
+ struct TfParserImpl;
+ std::unique_ptr<TfParserImpl> pTfParserImpl;
};
}