forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplace.hpp
More file actions
306 lines (270 loc) · 12.6 KB
/
Copy pathplace.hpp
File metadata and controls
306 lines (270 loc) · 12.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
// Copyright (C) 2018-2026 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <memory>
#include <string>
#include <vector>
#include "openvino/frontend/visibility.hpp"
namespace ov {
namespace frontend {
/// \brief An interface for identifying a place in a graph and iterate over it; can refer to
/// an operation node, tensor, port etc.
///
/// \note Each front end implementation provides specialization of this interface to
/// represent a place in a model graph. Various methods in the front end classes accept and
/// retrieve instances of Place to point to particular node part which should be modified or
/// satisfies some criteria. For example, this class is used to report model inputs
/// and outputs, for searching operations and tensors by name, for setting shape etc.
///
/// Place can refer to Tensor, Input Edge, Input Port, Operation, Output Port, Output Edge
///
/// [Tensor A]
/// |
/// | [Input Edge]
/// |
/// V
/// -------------------
/// [ [Input Port 0] ]
/// [ ]
/// [ Operation A ]
/// [ ]
/// [ [Output Port 0] ]
/// -------------------
/// |
/// | [Output Edge]
/// |
/// V
/// [Tensor B]
/// |
/// | [Input Edge]
/// |
/// V
/// -------------------
/// [ [Input Port 0] ]
/// [ ]
/// [ Operation B ]
/// [ ]
/// [ [Output Port 0] ]
/// -------------------
/// |
/// | [Output Edge]
/// |
/// V
/// [Tensor C]
///
class FRONTEND_API Place {
public:
typedef std::shared_ptr<Place> Ptr;
virtual ~Place();
/// \brief All associated names (synonyms) that identify this place in the graph in a
/// framework specific way
///
/// \return A vector of strings each representing a name that identifies this place in
/// the graph. Can be empty if there are no names associated with this place or name
/// cannot be attached.
virtual std::vector<std::string> get_names() const;
/// \brief Returns references to all operation nodes that consume data from this place
/// \note It can be called for any kind of graph place searching for the first consuming
/// operations. It is optional if place has only one output port
///
/// \return A vector with all operation node references that consumes data from this
/// place
virtual std::vector<Ptr> get_consuming_operations() const;
/// \brief Returns references to all operation nodes that consume data from this place
/// for specified output port
///
/// \note It can be called for any kind of graph place searching for the first consuming
/// operations.
///
/// \param output_port_index If place is an operational node it specifies which output
/// port should be considered.
///
/// \return A vector with all operation node references that consumes data from this
/// place
virtual std::vector<Ptr> get_consuming_operations(int output_port_index) const;
/// \brief Returns references to all operation nodes that consume data from this place
/// for specified output port
///
/// \note It can be called for any kind of graph place searching for the first consuming
/// operations.
///
/// \param outputName If a given place is itself an operation node, this specifies name
/// of output port group
///
/// \return A vector with all operation node references that consumes data from this
/// place
virtual std::vector<Ptr> get_consuming_operations(const std::string& outputName) const;
/// \brief Returns references to all operation nodes that consume data from this place
/// for specified output port
///
/// \note It can be called for any kind of graph place searching for the first consuming
/// operations.
///
/// \param outputName If a given place is itself an operation node, this specifies name
/// of output port group, each group can have multiple ports
///
/// \param outputPortIndex If place is an operational node it specifies which output
/// port should be considered.
///
/// \return A vector with all operation node references that consumes data from this
/// place
virtual std::vector<Ptr> get_consuming_operations(const std::string& outputName, int outputPortIndex) const;
/// \brief Returns a tensor place that gets data from this place; applicable for
/// operations, output ports and output edges which have only one output port
///
/// \return A tensor place which hold the resulting value for this place
virtual Ptr get_target_tensor() const;
/// \brief Returns a tensor place that gets data from this place; applicable for operations
///
/// \param outputName Name of output port group
///
/// \return A tensor place which hold the resulting value for this place
virtual Ptr get_target_tensor(const std::string& outputName) const;
/// \brief Returns a tensor place that gets data from this place; applicable for operations
///
/// \param outputName Name of output port group, each group can have multiple ports
///
/// \param outputPortIndex Output port index if the current place is an operation node
/// and has multiple output ports
///
/// \return A tensor place which hold the resulting value for this place
virtual Ptr get_target_tensor(const std::string& outputName, int outputPortIndex) const;
/// \brief Returns a tensor place that gets data from this place; applicable for operations
///
/// \param output_port_index Output port index if the current place is an operation node
/// and has multiple output ports
///
/// \return A tensor place which hold the resulting value for this place
virtual Ptr get_target_tensor(int output_port_index) const;
/// \brief Returns a tensor place that supplies data for this place; applicable for
/// operations, input ports and input edges which have only one input port
///
/// \return A tensor place which supplies data for this place
virtual Ptr get_source_tensor() const;
/// \brief Returns a tensor place that supplies data for this place; applicable for operations
///
/// \param input_port_index Input port index for operational nodes.
///
/// \return A tensor place which supplies data for this place
virtual Ptr get_source_tensor(int input_port_index) const;
/// \brief Returns a tensor place that supplies data for this place; applicable for operations
///
/// \param inputName Name of input port group
///
/// \return A tensor place which supplies data for this place
virtual Ptr get_source_tensor(const std::string& inputName) const;
/// \brief Returns a tensor place that supplies data for this place; applicable for operations
///
/// \param inputName If a given place is itself an operation node, this specifies name
/// of output port group, each group can have multiple ports
///
/// \param inputPortIndex Input port index for operational nodes.
///
/// \return A tensor place which supplies data for this place
virtual Ptr get_source_tensor(const std::string& inputName, int inputPortIndex) const;
/// \brief Get an operation node place that immediately produces data for this place;
/// applicable if place has only one input port
///
/// \return An operation place that produces data for this place
virtual Ptr get_producing_operation() const;
/// \brief Get an operation node place that immediately produces data for this place
///
/// \param input_port_index If a given place is itself an operation node, this specifies
/// a port index
///
/// \return An operation place that produces data for this place
virtual Ptr get_producing_operation(int input_port_index) const;
/// \brief Get an operation node place that immediately produces data for this place
///
/// \param inputName If a given place is itself an operation node, this specifies name
/// of output port group
///
/// \return An operation place that produces data for this place
virtual Ptr get_producing_operation(const std::string& inputName) const;
/// \brief Get an operation node place that immediately produces data for this place
///
/// \param inputName If a given place is itself an operation node, this specifies name
/// of output port group, each group can have multiple ports
///
/// \param inputPortIndex If a given place is itself an operation node, this specifies a
/// port index
///
/// \return An operation place that produces data for this place
virtual Ptr get_producing_operation(const std::string& inputName, int inputPortIndex) const;
/// \brief Returns a port that produces data for this place
virtual Ptr get_producing_port() const;
/// \brief For operation node returns reference to an input port; applicable if
/// operation node has only one input port
///
/// \return Input port place or nullptr if not exists
virtual Ptr get_input_port() const;
/// \brief For operation node returns reference to an input port with specified index
///
/// \param input_port_index Input port index
///
/// \return Appropriate input port place or nullptr if not exists
virtual Ptr get_input_port(int input_port_index) const;
/// \brief For operation node returns reference to an input port with specified name;
/// applicable if port group has only one input port
///
/// \param input_name Name of port group
///
/// \return Appropriate input port place or nullptr if not exists
virtual Ptr get_input_port(const std::string& input_name) const;
/// \brief For operation node returns reference to an input port with specified name and
/// index
///
/// \param input_name Name of port group, each group can have multiple ports
///
/// \param input_port_index Input port index in a group
///
/// \return Appropriate input port place or nullptr if not exists
virtual Ptr get_input_port(const std::string& input_name, int input_port_index) const;
/// \brief For operation node returns reference to an output port; applicable for
/// operations with only one output port
///
/// \return Appropriate output port place or nullptr if not exists
virtual Ptr get_output_port() const;
/// \brief For operation node returns reference to an output port with specified index
///
/// \param output_port_index Output port index
///
/// \return Appropriate output port place or nullptr if not exists
virtual Ptr get_output_port(int output_port_index) const;
/// \brief For operation node returns reference to an output port with specified name;
/// applicable if port group has only one output port
///
/// \param output_name Name of output port group
///
/// \return Appropriate output port place or nullptr if not exists
virtual Ptr get_output_port(const std::string& output_name) const;
/// \brief For operation node returns reference to an output port with specified name
/// and index
///
/// \param output_name Name of output port group, each group can have multiple ports
///
/// \param output_port_index Output port index
///
/// \return Appropriate output port place or nullptr if not exists
virtual Ptr get_output_port(const std::string& output_name, int output_port_index) const;
/// \brief Returns all input ports that consume data flows through this place
virtual std::vector<Place::Ptr> get_consuming_ports() const;
/// \brief Returns true if this place is input for a model.
virtual bool is_input() const;
/// \brief Returns true if this place is output for a model.
virtual bool is_output() const;
/// \brief Returns true if another place is the same as this place.
///
/// \param another Another place object
virtual bool is_equal(const Ptr& another) const;
/// \brief Returns true if another place points to the same data.
///
/// \note The same data means all places on path: output port -> output edge -> tensor
/// -> input edge -> input port.
///
/// \param another Another place object
virtual bool is_equal_data(const Ptr& another) const;
};
} // namespace frontend
} // namespace ov