blob: 0e31ad44610b5462c7cd35bfdda3e02adbcbec2c [file] [log] [blame]
Laurent Carlier749294b2020-06-01 09:03:17 +01001//
telsoa014fcda012018-03-09 14:13:49 +00002// Copyright © 2017 Arm Ltd. All rights reserved.
David Beckecb56cd2018-09-05 12:52:57 +01003// SPDX-License-Identifier: MIT
telsoa014fcda012018-03-09 14:13:49 +00004//
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
16namespace armnnCaffeParser
17{
18
Jim Flynnb4d7eae2019-05-01 14:44:27 +010019using BindingPointInfo = armnn::BindingPointInfo;
telsoa014fcda012018-03-09 14:13:49 +000020
21class ICaffeParser;
22using ICaffeParserPtr = std::unique_ptr<ICaffeParser, void(*)(ICaffeParser* parser)>;
23
24class ICaffeParser
25{
26public:
27 static ICaffeParser* CreateRaw();
28 static ICaffeParserPtr Create();
29 static void Destroy(ICaffeParser* parser);
30
telsoa01c577f2c2018-08-31 09:22:23 +010031 /// Create the network from a protobuf text file on the disk.
Kevin Mayef33cb12021-01-29 14:24:57 +000032 armnn::INetworkPtr CreateNetworkFromTextFile(
telsoa014fcda012018-03-09 14:13:49 +000033 const char* graphFile,
34 const std::map<std::string, armnn::TensorShape>& inputShapes,
Kevin Mayef33cb12021-01-29 14:24:57 +000035 const std::vector<std::string>& requestedOutputs);
telsoa014fcda012018-03-09 14:13:49 +000036
telsoa01c577f2c2018-08-31 09:22:23 +010037 /// Create the network from a protobuf binary file on the disk.
Kevin Mayef33cb12021-01-29 14:24:57 +000038 armnn::INetworkPtr CreateNetworkFromBinaryFile(
telsoa014fcda012018-03-09 14:13:49 +000039 const char* graphFile,
40 const std::map<std::string, armnn::TensorShape>& inputShapes,
Kevin Mayef33cb12021-01-29 14:24:57 +000041 const std::vector<std::string>& requestedOutputs);
telsoa014fcda012018-03-09 14:13:49 +000042
telsoa01c577f2c2018-08-31 09:22:23 +010043 /// Create the network directly from protobuf text in a string. Useful for debugging/testin.g
Kevin Mayef33cb12021-01-29 14:24:57 +000044 armnn::INetworkPtr CreateNetworkFromString(
telsoa014fcda012018-03-09 14:13:49 +000045 const char* protoText,
46 const std::map<std::string, armnn::TensorShape>& inputShapes,
Kevin Mayef33cb12021-01-29 14:24:57 +000047 const std::vector<std::string>& requestedOutputs);
telsoa014fcda012018-03-09 14:13:49 +000048
telsoa01c577f2c2018-08-31 09:22:23 +010049 /// 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 +000050 BindingPointInfo GetNetworkInputBindingInfo(const std::string& name) const;
telsoa014fcda012018-03-09 14:13:49 +000051
telsoa01c577f2c2018-08-31 09:22:23 +010052 /// 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 +000053 BindingPointInfo GetNetworkOutputBindingInfo(const std::string& name) const;
telsoa014fcda012018-03-09 14:13:49 +000054
Kevin Mayef33cb12021-01-29 14:24:57 +000055private:
56 friend class CaffeParser;
57 friend class RecordByRecordCaffeParser;
58
59 ICaffeParser();
60 ~ICaffeParser();
61
62 class CaffeParserImpl;
63 std::unique_ptr<CaffeParserImpl> pCaffeParserImpl;
telsoa014fcda012018-03-09 14:13:49 +000064};
65
66}