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/INetwork.hpp> |
| 8 | #include <armnn/Tensor.hpp> |
| 9 | |
| 10 | #include <memory> |
| 11 | #include <vector> |
| 12 | #include <map> |
| 13 | |
| 14 | namespace armnnOnnxParser |
| 15 | { |
| 16 | |
Jim Flynn | b4d7eae | 2019-05-01 14:44:27 +0100 | [diff] [blame] | 17 | using BindingPointInfo = armnn::BindingPointInfo; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 18 | |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 19 | class OnnxParserImpl; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 20 | class IOnnxParser; |
| 21 | using IOnnxParserPtr = std::unique_ptr<IOnnxParser, void(*)(IOnnxParser* parser)>; |
| 22 | |
| 23 | class IOnnxParser |
| 24 | { |
| 25 | public: |
| 26 | static IOnnxParser* CreateRaw(); |
| 27 | static IOnnxParserPtr Create(); |
| 28 | static void Destroy(IOnnxParser* parser); |
| 29 | |
| 30 | /// Create the network from a protobuf binary file on disk |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 31 | armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 32 | |
| 33 | /// Create the network from a protobuf text file on disk |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 34 | armnn::INetworkPtr CreateNetworkFromTextFile(const char* graphFile); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 35 | |
| 36 | /// Create the network directly from protobuf text in a string. Useful for debugging/testing |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 37 | armnn::INetworkPtr CreateNetworkFromString(const std::string& protoText); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 38 | |
Narumol Prangnawarat | 1b11f32 | 2021-10-13 11:44:50 +0100 | [diff] [blame] | 39 | /// Create the network from a protobuf binary file on disk, with inputShapes specified |
| 40 | armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile, |
| 41 | const std::map<std::string, armnn::TensorShape>& inputShapes); |
| 42 | |
| 43 | /// Create the network from a protobuf text file on disk, with inputShapes specified |
| 44 | armnn::INetworkPtr CreateNetworkFromTextFile(const char* graphFile, |
| 45 | const std::map<std::string, armnn::TensorShape>& inputShapes); |
| 46 | |
| 47 | /// Create the network directly from protobuf text in a string, with inputShapes specified. |
| 48 | /// Useful for debugging/testing |
| 49 | armnn::INetworkPtr CreateNetworkFromString(const std::string& protoText, |
| 50 | const std::map<std::string, armnn::TensorShape>& inputShapes); |
| 51 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 52 | /// 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] | 53 | BindingPointInfo GetNetworkInputBindingInfo(const std::string& name) const; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 54 | |
| 55 | /// 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] | 56 | BindingPointInfo GetNetworkOutputBindingInfo(const std::string& name) const; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 57 | |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 58 | private: |
| 59 | IOnnxParser(); |
| 60 | ~IOnnxParser(); |
| 61 | |
| 62 | std::unique_ptr<OnnxParserImpl> pOnnxParserImpl; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 63 | }; |
| 64 | |
| 65 | } |