blob: 89c22c03de9ad7e8e334f7a31fb402fd7e60b172 [file] [log] [blame]
telsoa01c577f2c2018-08-31 09:22:23 +01001//
Mike Kelly2ae32242022-11-25 13:55:24 +00002// Copyright © 2017,2022 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
Mike Kelly2ae32242022-11-25 13:55:24 +000030 /// 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
telsoa01c577f2c2018-08-31 09:22:23 +010037 /// Create the network from a protobuf binary file on disk
Kevin Mayef33cb12021-01-29 14:24:57 +000038 armnn::INetworkPtr CreateNetworkFromBinaryFile(const char* graphFile);
telsoa01c577f2c2018-08-31 09:22:23 +010039
40 /// Create the network from a protobuf text file on disk
Kevin Mayef33cb12021-01-29 14:24:57 +000041 armnn::INetworkPtr CreateNetworkFromTextFile(const char* graphFile);
telsoa01c577f2c2018-08-31 09:22:23 +010042
43 /// Create the network directly from protobuf text in a string. Useful for debugging/testing
Kevin Mayef33cb12021-01-29 14:24:57 +000044 armnn::INetworkPtr CreateNetworkFromString(const std::string& protoText);
telsoa01c577f2c2018-08-31 09:22:23 +010045
Narumol Prangnawarat1b11f322021-10-13 11:44:50 +010046 /// 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
telsoa01c577f2c2018-08-31 09:22:23 +010059 /// 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 +000060 BindingPointInfo GetNetworkInputBindingInfo(const std::string& name) const;
telsoa01c577f2c2018-08-31 09:22:23 +010061
62 /// 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 +000063 BindingPointInfo GetNetworkOutputBindingInfo(const std::string& name) const;
telsoa01c577f2c2018-08-31 09:22:23 +010064
Kevin Mayef33cb12021-01-29 14:24:57 +000065private:
66 IOnnxParser();
67 ~IOnnxParser();
68
69 std::unique_ptr<OnnxParserImpl> pOnnxParserImpl;
telsoa01c577f2c2018-08-31 09:22:23 +010070 };
71
72 }