1 // Copyright (c) 2018 Intel Corporation
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
28 #include <ie_builders.hpp>
29 #include <inference_engine.hpp>
31 #include <ie_api_impl.hpp>
34 // namespace IE Python
35 namespace InferenceEnginePython {
41 explicit Port(const std::vector<size_t> &shapes);
43 InferenceEngine::Port actual;
44 std::vector<size_t> shape;
48 InferenceEngine::ILayer::CPtr layer_ptr;
52 std::map<std::string, std::string> parameters;
53 std::map<std::string, InferenceEngine::Blob::Ptr> constant_data;
54 std::vector<Port> in_ports;
55 std::vector<Port> out_ports;
59 PortInfo(size_t layer_id, size_t port_id);
61 PortInfo() : actual(0, 0) {}
63 InferenceEngine::PortInfo actual;
69 Connection() : actual(InferenceEngine::PortInfo(0), InferenceEngine::PortInfo(0)) {}
71 Connection(PortInfo input, PortInfo output);
73 InferenceEngine::Connection actual;
79 InferenceEngine::INetwork::Ptr actual;
82 std::vector<ILayer> layers;
83 std::vector<ILayer> inputs;
84 std::vector<ILayer> outputs;
86 std::vector<Connection> getLayerConnections(size_t layer_id);
88 IENetwork to_ie_network();
91 struct NetworkBuilder {
92 InferenceEngine::Builder::Network::Ptr network_ptr;
94 explicit NetworkBuilder(const std::string &name);
96 NetworkBuilder() = default;
98 NetworkBuilder from_ie_network(const InferenceEnginePython::IENetwork &icnn_net);
102 std::vector<LayerBuilder> getLayers();
104 LayerBuilder getLayer(size_t layer_id);
106 void removeLayer(const LayerBuilder &layer);
108 size_t addLayer(const LayerBuilder &layer);
110 size_t addAndConnectLayer(const std::vector<PortInfo> &input, const LayerBuilder &layer);
112 const std::vector<Connection> getLayerConnections(const LayerBuilder &layer);
114 void disconnect(const Connection &connection);
116 void connect(const PortInfo &input, const PortInfo &output);
119 struct LayerBuilder {
120 InferenceEngine::Builder::Layer actual;
123 LayerBuilder(const std::string &type, const std::string &name);
125 LayerBuilder() : actual("", "") {}
127 LayerBuilder from_ilayer(const ILayer &ilayer);
129 const std::string &getName();
131 void setName(const std::string &name);
133 const std::string &getType();
135 void setType(const std::string &type);
137 std::vector<Port> getInputPorts();
139 void setInputPorts(const std::vector<Port> ports);
141 std::vector<Port> getOutputPorts();
143 void setOutputPorts(const std::vector<Port> ports);
146 std::map<std::string, std::string> getParameters();
148 void setParameters(std::map<std::string, std::string> params_map);
152 std::map<std::string, InferenceEngine::Blob::Ptr> getConstantData();
154 InferenceEngine::Blob::Ptr allocateBlob(std::vector<size_t> dims, const std::string &precision);
156 void setConstantData(const std::map<std::string, InferenceEngine::Blob::Ptr> &const_data);
158 // TODO( ): Fix LAyerBuilder object copying - pass by reference
159 // void addConstantData(const std::string & name, InferenceEngine::Blob::Ptr data);
161 } // namespace InferenceEnginePython