Laurent Carlier | 749294b | 2020-06-01 09:03:17 +0100 | [diff] [blame] | 1 | // |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 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 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [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 armnnCaffeParser |
| 17 | { |
| 18 | |
Jim Flynn | b4d7eae | 2019-05-01 14:44:27 +0100 | [diff] [blame] | 19 | using BindingPointInfo = armnn::BindingPointInfo; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 20 | |
| 21 | class ICaffeParser; |
| 22 | using ICaffeParserPtr = std::unique_ptr<ICaffeParser, void(*)(ICaffeParser* parser)>; |
| 23 | |
| 24 | class ICaffeParser |
| 25 | { |
| 26 | public: |
| 27 | static ICaffeParser* CreateRaw(); |
| 28 | static ICaffeParserPtr Create(); |
| 29 | static void Destroy(ICaffeParser* parser); |
| 30 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 31 | /// Create the network from a protobuf text file on the disk. |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 32 | armnn::INetworkPtr CreateNetworkFromTextFile( |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 33 | const char* graphFile, |
| 34 | const std::map<std::string, armnn::TensorShape>& inputShapes, |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 35 | const std::vector<std::string>& requestedOutputs); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 36 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 37 | /// Create the network from a protobuf binary file on the disk. |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 38 | armnn::INetworkPtr CreateNetworkFromBinaryFile( |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 39 | const char* graphFile, |
| 40 | const std::map<std::string, armnn::TensorShape>& inputShapes, |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 41 | const std::vector<std::string>& requestedOutputs); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 42 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 43 | /// Create the network directly from protobuf text in a string. Useful for debugging/testin.g |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 44 | armnn::INetworkPtr CreateNetworkFromString( |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 45 | const char* protoText, |
| 46 | const std::map<std::string, armnn::TensorShape>& inputShapes, |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 47 | const std::vector<std::string>& requestedOutputs); |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 48 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 49 | /// Retrieve binding info (layer id and tensor info) for the network input identified by the given layer name. |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 50 | BindingPointInfo GetNetworkInputBindingInfo(const std::string& name) const; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 51 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 52 | /// Retrieve binding info (layer id and tensor info) for the network output identified by the given layer name. |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 53 | BindingPointInfo GetNetworkOutputBindingInfo(const std::string& name) const; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 54 | |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 55 | private: |
| 56 | friend class CaffeParser; |
| 57 | friend class RecordByRecordCaffeParser; |
| 58 | |
| 59 | ICaffeParser(); |
| 60 | ~ICaffeParser(); |
| 61 | |
| 62 | class CaffeParserImpl; |
| 63 | std::unique_ptr<CaffeParserImpl> pCaffeParserImpl; |
telsoa01 | 4fcda01 | 2018-03-09 14:13:49 +0000 | [diff] [blame] | 64 | }; |
| 65 | |
| 66 | } |