exec_graph_info.hpp
Go to the documentation of this file.
1 // Copyright (C) 2018-2020 Intel Corporation
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 /**
6  * @brief A file defines names to be used by plugins to create execution graph.
7  * It's an API between plugin and WorkBench tool.
8  * @file exec_graph_info.hpp
9  */
10 
11 #pragma once
12 
13 #include <ie_api.h>
14 #include <ie_parameter.hpp>
15 #include <string>
16 
17 #include <ngraph/node.hpp>
18 
19 /**
20  * @brief A namespace with const values for Execution Graph parameters names.
21  *
22  * Executable Graph Info is represented in CNNNetwork format with general ExecutionNode nodes inside
23  * including connections between the nodes. Each node describes an executable hardware-specific
24  * primitive and stores its parameters within ExecutionNode::get_rt_info map.
25  * There is a list of general keys for the parameters map.
26  */
28 
29 /**
30  * @ingroup ie_dev_exec_graph
31  * @brief Used to get a string of layer names separated by a comma
32  * from the original IR, which were fused/merged to the current executable primitive.
33  */
34 static const char ORIGINAL_NAMES[] = "originalLayersNames";
35 
36 /**
37  * @ingroup ie_dev_exec_graph
38  * @brief Used to get a type of the executable primitive.
39  */
40 static const char IMPL_TYPE[] = "primitiveType";
41 
42 /**
43  * @ingroup ie_dev_exec_graph
44  * @brief Used to get output precisions of the executable primitive.
45  */
46 static const char OUTPUT_PRECISIONS[] = "outputPrecisions";
47 
48 /**
49  * @ingroup ie_dev_exec_graph
50  * @brief Used to get a value of execution time of the executable primitive.
51  */
52 static const char PERF_COUNTER[] = "execTimeMcs";
53 
54 /**
55  * @ingroup ie_dev_exec_graph
56  * @brief Used to get output layouts of primitive.
57  */
58 static const char OUTPUT_LAYOUTS[] = "outputLayouts";
59 
60 /**
61  * @ingroup ie_dev_exec_graph
62  * @brief Used to get an execution order of primitive.
63  */
64 static const char EXECUTION_ORDER[] = "execOrder";
65 
66 /**
67  * @ingroup ie_dev_exec_graph
68  * @brief Used to get a type of primitive.
69  */
70 static const char LAYER_TYPE[] = "layerType";
71 
72 /**
73  * @ingroup ie_dev_exec_graph
74  * @brief Used to get runtime precision of the executable primitive.
75  */
76 static const char RUNTIME_PRECISION[] = "runtimePrecision";
77 
78 /**
79  * @ingroup ie_dev_exec_graph
80  * @brief The Execution node which is used to represent node in execution graph.
81  *
82  * It contains the following type of information in node runtime information:
83  * - ExecGraphInfoSerialization::ORIGINAL_NAMES
84  * - ExecGraphInfoSerialization::IMPL_TYPE
85  * - ExecGraphInfoSerialization::OUTPUT_PRECISIONS
86  * - ExecGraphInfoSerialization::PERF_COUNTER
87  * - ExecGraphInfoSerialization::OUTPUT_LAYOUTS
88  * - ExecGraphInfoSerialization::EXECUTION_ORDER
89  * - ExecGraphInfoSerialization::LAYER_TYPE
90  * - ExecGraphInfoSerialization::RUNTIME_PRECISION
91  */
92 class INFERENCE_ENGINE_API_CLASS(ExecutionNode) : public ngraph::Node {
93 public:
94  static constexpr ngraph::NodeTypeInfo type_info { "ExecutionNode", 0 };
95  const ngraph::NodeTypeInfo& get_type_info() const override;
96 
97  /**
98  * A default constructor with no node inputs and 0 output ports.
99  */
100  ExecutionNode() = default;
101 
102  /**
103  * @brief Constructs a new execution node with a given parameters
104  *
105  * @param[in] arguments Inputs nodes
106  * @param[in] output_size A number of output ports
107  */
108  ExecutionNode(const ngraph::OutputVector& arguments, size_t output_size = 1) :
109  Node(arguments, output_size) { }
110 
111  /**
112  * @brief Creates a new execution node with the same state, but different input nodes
113  *
114  * @param[in] inputs The input nodes
115  *
116  * @return A newly created execution node
117  */
118  std::shared_ptr<ngraph::Node> clone_with_new_inputs(const ngraph::OutputVector& inputs) const override {
119  auto cloned = std::make_shared<ExecutionNode>();
120 
121  cloned->set_arguments(inputs);
122 
123  for (auto kvp : get_rt_info())
124  cloned->get_rt_info()[kvp.first] = kvp.second;
125 
126  for (size_t i = 0; i < get_output_size(); ++i)
127  cloned->set_output_type(i, get_output_element_type(i), get_output_partial_shape(i));
128 
129  return cloned;
130  }
131 
132  /**
133  * @brief Visits attributes of the node
134  *
135  * @param[in] visitor An attribute visitor
136  *
137  * @return Returns `true` if an operation has completed successfully
138  */
139  bool visit_attributes(ngraph::AttributeVisitor& /*visitor*/) override {
140  return true;
141  }
142 };
143 
144 } // namespace ExecGraphInfoSerialization
bool visit_attributes(ngraph::AttributeVisitor &) override
Visits attributes of the node.
Definition: exec_graph_info.hpp:139
ExecutionNode(const ngraph::OutputVector &arguments, size_t output_size=1)
Constructs a new execution node with a given parameters.
Definition: exec_graph_info.hpp:108
std::shared_ptr< ngraph::Node > clone_with_new_inputs(const ngraph::OutputVector &inputs) const override
Creates a new execution node with the same state, but different input nodes.
Definition: exec_graph_info.hpp:118
static const char LAYER_TYPE[]
Used to get a type of primitive.
Definition: exec_graph_info.hpp:70
static const char RUNTIME_PRECISION[]
Used to get runtime precision of the executable primitive.
Definition: exec_graph_info.hpp:76
static const char EXECUTION_ORDER[]
Used to get an execution order of primitive.
Definition: exec_graph_info.hpp:64
static const char OUTPUT_LAYOUTS[]
Used to get output layouts of primitive.
Definition: exec_graph_info.hpp:58
static const char OUTPUT_PRECISIONS[]
Used to get output precisions of the executable primitive.
Definition: exec_graph_info.hpp:46
static const char PERF_COUNTER[]
Used to get a value of execution time of the executable primitive.
Definition: exec_graph_info.hpp:52
static const char IMPL_TYPE[]
Used to get a type of the executable primitive.
Definition: exec_graph_info.hpp:40
static const char ORIGINAL_NAMES[]
Used to get a string of layer names separated by a comma from the original IR, which were fused/merge...
Definition: exec_graph_info.hpp:34
A namespace with const values for Execution Graph parameters names.
Definition: exec_graph_info.hpp:27