b2e5d10b69f73d3dba6f7bffef6ebefe8f462ee8
[platform/upstream/armnn.git] / include / armnnDeserializer / IDeserializer.hpp
1 //
2 // Copyright © 2017 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
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
16 namespace armnnDeserializer
17 {
18 struct BindingPointInfo
19 {
20     armnn::LayerBindingId   m_BindingId;
21     armnn::TensorInfo       m_TensorInfo;
22 };
23
24 class IDeserializer;
25 using IDeserializerPtr = std::unique_ptr<IDeserializer, void(*)(IDeserializer* parser)>;
26
27 class IDeserializer
28 {
29 public:
30     static IDeserializer* CreateRaw();
31     static IDeserializerPtr Create();
32     static void Destroy(IDeserializer* parser);
33
34     /// Create an input network from binary file contents
35     virtual armnn::INetworkPtr CreateNetworkFromBinary(const std::vector<uint8_t>& binaryContent) = 0;
36
37     /// Create an input network from a binary input stream
38     virtual armnn::INetworkPtr CreateNetworkFromBinary(std::istream& binaryContent) = 0;
39
40     /// Retrieve binding info (layer id and tensor info) for the network input identified by
41     /// the given layer name and layers id
42     virtual BindingPointInfo GetNetworkInputBindingInfo(unsigned int layerId,
43                                                         const std::string& name) const = 0;
44
45     /// Retrieve binding info (layer id and tensor info) for the network output identified by
46     /// the given layer name and layers id
47     virtual BindingPointInfo GetNetworkOutputBindingInfo(unsigned int layerId,
48                                                          const std::string& name) const = 0;
49
50 protected:
51     virtual ~IDeserializer() {};
52
53 };
54 } //namespace armnnDeserializer