From ef33cb192eef332fb3a26be742b341288421e5bc Mon Sep 17 00:00:00 2001 From: Kevin May Date: Fri, 29 Jan 2021 14:24:57 +0000 Subject: IVGCVSW-5592 Implement Pimpl Idiom for Caffe and Onnx Parsers Signed-off-by: Kevin May Change-Id: I760dc4f33c0f87113cda2fa924da70f2e8c19025 --- include/armnnCaffeParser/ICaffeParser.hpp | 27 +++++++++++++++++---------- include/armnnOnnxParser/IOnnxParser.hpp | 18 +++++++++++------- 2 files changed, 28 insertions(+), 17 deletions(-) (limited to 'include') diff --git a/include/armnnCaffeParser/ICaffeParser.hpp b/include/armnnCaffeParser/ICaffeParser.hpp index a1ba59fbc6..0e31ad4461 100644 --- a/include/armnnCaffeParser/ICaffeParser.hpp +++ b/include/armnnCaffeParser/ICaffeParser.hpp @@ -29,31 +29,38 @@ public: static void Destroy(ICaffeParser* 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& inputShapes, - const std::vector& requestedOutputs) = 0; + const std::vector& 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& inputShapes, - const std::vector& requestedOutputs) = 0; + const std::vector& requestedOutputs); /// Create the network directly from protobuf text in a string. Useful for debugging/testin.g - virtual armnn::INetworkPtr CreateNetworkFromString( + armnn::INetworkPtr CreateNetworkFromString( const char* protoText, const std::map& inputShapes, - const std::vector& requestedOutputs) = 0; + const std::vector& 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 ~ICaffeParser() {}; +private: + friend class CaffeParser; + friend class RecordByRecordCaffeParser; + + ICaffeParser(); + ~ICaffeParser(); + + class CaffeParserImpl; + std::unique_ptr pCaffeParserImpl; }; } \ No newline at end of file diff --git a/include/armnnOnnxParser/IOnnxParser.hpp b/include/armnnOnnxParser/IOnnxParser.hpp index d6b9399dd5..f9d692738d 100644 --- a/include/armnnOnnxParser/IOnnxParser.hpp +++ b/include/armnnOnnxParser/IOnnxParser.hpp @@ -16,6 +16,7 @@ namespace armnnOnnxParser using BindingPointInfo = armnn::BindingPointInfo; +class OnnxParserImpl; class IOnnxParser; using IOnnxParserPtr = std::unique_ptr; @@ -27,22 +28,25 @@ public: static void Destroy(IOnnxParser* parser); /// Create the network from a protobuf binary file on disk - virtual armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile) = 0; + armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile); /// Create the network from a protobuf text file on disk - virtual armnn::INetworkPtr CreateNetworkFromTextFile(const char* graphFile) = 0; + armnn::INetworkPtr CreateNetworkFromTextFile(const char* graphFile); /// Create the network directly from protobuf text in a string. Useful for debugging/testing - virtual armnn::INetworkPtr CreateNetworkFromString(const std::string& protoText) = 0; + armnn::INetworkPtr CreateNetworkFromString(const std::string& protoText); /// 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 ~IOnnxParser() {}; +private: + IOnnxParser(); + ~IOnnxParser(); + + std::unique_ptr pOnnxParserImpl; }; } -- cgit v1.2.1