telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 1 | // |
Mike Kelly | 2ae3224 | 2022-11-25 13:55:24 +0000 | [diff] [blame] | 2 | // Copyright © 2017,2022 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 | |
Mike Kelly | 2ae3224 | 2022-11-25 13:55:24 +0000 | [diff] [blame] | 30 | /// Create the network from a protobuf binary vector |
| 31 | armnn::INetworkPtr CreateNetworkFromBinary(const std::vector<uint8_t>& binaryContent); |
| 32 | |
| 33 | /// Create the network from a protobuf binary vector, with inputShapes specified |
| 34 | armnn::INetworkPtr CreateNetworkFromBinary(const std::vector<uint8_t>& binaryContent, |
| 35 | const std::map<std::string, armnn::TensorShape>& inputShapes); |
| 36 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 37 | /// Create the network from a protobuf binary file on disk |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 38 | armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 39 | |
| 40 | /// Create the network from a protobuf text file on disk |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 41 | armnn::INetworkPtr CreateNetworkFromTextFile(const char* graphFile); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 42 | |
| 43 | /// 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] | 44 | armnn::INetworkPtr CreateNetworkFromString(const std::string& protoText); |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 45 | |
Narumol Prangnawarat | 1b11f32 | 2021-10-13 11:44:50 +0100 | [diff] [blame] | 46 | /// Create the network from a protobuf binary file on disk, with inputShapes specified |
| 47 | armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile, |
| 48 | const std::map<std::string, armnn::TensorShape>& inputShapes); |
| 49 | |
| 50 | /// Create the network from a protobuf text file on disk, with inputShapes specified |
| 51 | armnn::INetworkPtr CreateNetworkFromTextFile(const char* graphFile, |
| 52 | const std::map<std::string, armnn::TensorShape>& inputShapes); |
| 53 | |
| 54 | /// Create the network directly from protobuf text in a string, with inputShapes specified. |
| 55 | /// Useful for debugging/testing |
| 56 | armnn::INetworkPtr CreateNetworkFromString(const std::string& protoText, |
| 57 | const std::map<std::string, armnn::TensorShape>& inputShapes); |
| 58 | |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 59 | /// 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] | 60 | BindingPointInfo GetNetworkInputBindingInfo(const std::string& name) const; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 61 | |
| 62 | /// 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] | 63 | BindingPointInfo GetNetworkOutputBindingInfo(const std::string& name) const; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 64 | |
Kevin May | ef33cb1 | 2021-01-29 14:24:57 +0000 | [diff] [blame] | 65 | private: |
| 66 | IOnnxParser(); |
| 67 | ~IOnnxParser(); |
| 68 | |
| 69 | std::unique_ptr<OnnxParserImpl> pOnnxParserImpl; |
telsoa01 | c577f2c | 2018-08-31 09:22:23 +0100 | [diff] [blame] | 70 | }; |
| 71 | |
| 72 | } |