blob: ba7fc83f93b6b89d182c7f3866c84c6cca00416a [file] [log] [blame]
telsoa01c577f2c2018-08-31 09:22:23 +01001//
2// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa01c577f2c2018-08-31 09:22:23 +01004//
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
14namespace armnnOnnxParser
15{
16
Jim Flynnb4d7eae2019-05-01 14:44:27 +010017using BindingPointInfo = armnn::BindingPointInfo;
telsoa01c577f2c2018-08-31 09:22:23 +010018
Kevin Mayef33cb12021-01-29 14:24:57 +000019class OnnxParserImpl;
telsoa01c577f2c2018-08-31 09:22:23 +010020class IOnnxParser;
21using IOnnxParserPtr = std::unique_ptr<IOnnxParser, void(*)(IOnnxParser* parser)>;
22
23class IOnnxParser
24{
25public:
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 Mayef33cb12021-01-29 14:24:57 +000031 armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile);
telsoa01c577f2c2018-08-31 09:22:23 +010032
33 /// Create the network from a protobuf text file on disk
Kevin Mayef33cb12021-01-29 14:24:57 +000034 armnn::INetworkPtr CreateNetworkFromTextFile(const char* graphFile);
telsoa01c577f2c2018-08-31 09:22:23 +010035
36 /// Create the network directly from protobuf text in a string. Useful for debugging/testing
Kevin Mayef33cb12021-01-29 14:24:57 +000037 armnn::INetworkPtr CreateNetworkFromString(const std::string& protoText);
telsoa01c577f2c2018-08-31 09:22:23 +010038
Narumol Prangnawarat1b11f322021-10-13 11:44:50 +010039 /// 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
telsoa01c577f2c2018-08-31 09:22:23 +010052 /// Retrieve binding info (layer id and tensor info) for the network input identified by the given layer name
Kevin Mayef33cb12021-01-29 14:24:57 +000053 BindingPointInfo GetNetworkInputBindingInfo(const std::string& name) const;
telsoa01c577f2c2018-08-31 09:22:23 +010054
55 /// Retrieve binding info (layer id and tensor info) for the network output identified by the given layer name
Kevin Mayef33cb12021-01-29 14:24:57 +000056 BindingPointInfo GetNetworkOutputBindingInfo(const std::string& name) const;
telsoa01c577f2c2018-08-31 09:22:23 +010057
Kevin Mayef33cb12021-01-29 14:24:57 +000058private:
59 IOnnxParser();
60 ~IOnnxParser();
61
62 std::unique_ptr<OnnxParserImpl> pOnnxParserImpl;
telsoa01c577f2c2018-08-31 09:22:23 +010063 };
64
65 }