|
3 | 3 |
|
4 | 4 | #pragma once |
5 | 5 |
|
| 6 | +#include <functional> |
6 | 7 | #include <limits> |
7 | 8 | #include <memory> |
8 | 9 | #include <string> |
@@ -83,10 +84,10 @@ class Node { |
83 | 84 | gsl::span<NodeArg* const> output_args, |
84 | 85 | const NodeAttributes* attributes, |
85 | 86 | std::string_view domain) { |
86 | | - Init(std::string{name}, std::string{op_type}, std::string{description}, |
87 | | - std::vector<NodeArg*>{input_args.begin(), input_args.end()}, |
88 | | - std::vector<NodeArg*>{output_args.begin(), output_args.end()}, |
89 | | - attributes, std::string{domain}); |
| 87 | + Init(name, op_type, description, |
| 88 | + input_args, |
| 89 | + output_args, |
| 90 | + attributes, domain); |
90 | 91 | } |
91 | 92 | #endif |
92 | 93 |
|
@@ -563,13 +564,13 @@ class Node { |
563 | 564 | ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Node); |
564 | 565 |
|
565 | 566 | #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) || defined(ORT_MINIMAL_BUILD_CUSTOM_OPS) |
566 | | - void Init(const std::string& name, |
567 | | - const std::string& op_type, |
568 | | - const std::string& description, |
569 | | - const std::vector<NodeArg*>& input_args, |
570 | | - const std::vector<NodeArg*>& output_args, |
| 567 | + void Init(std::string_view name, |
| 568 | + std::string_view op_type, |
| 569 | + std::string_view description, |
| 570 | + gsl::span<NodeArg* const> input_args, |
| 571 | + gsl::span<NodeArg* const> output_args, |
571 | 572 | const NodeAttributes* attributes, |
572 | | - const std::string& domain); |
| 573 | + std::string_view domain); |
573 | 574 | #endif |
574 | 575 |
|
575 | 576 | #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
@@ -1141,8 +1142,22 @@ class Graph { |
1141 | 1142 | */ |
1142 | 1143 | Status InlineFunction(Node& node); |
1143 | 1144 |
|
| 1145 | + /** |
| 1146 | + Directly insert the nodes in the function proto provided into the graph. |
| 1147 | + The function converts Constant nodes into the initializers in the graph. |
| 1148 | + It then creates a node in the graph for each of the function nodes. |
| 1149 | + All of the names are expected to be specialized, and, therefore unique. |
| 1150 | + See function_utils::Specialize(). |
| 1151 | +
|
| 1152 | + The Graph needs to be Resolve()d after this call. |
| 1153 | + @param func_to_inline |
| 1154 | + @returns Status indicating success or providing an error message. |
| 1155 | + */ |
| 1156 | + |
| 1157 | + Status InlineFunctionProto(const ONNX_NAMESPACE::FunctionProto& func_to_inline); |
| 1158 | + |
1144 | 1159 | /** Mark a NodeArg name as coming from the outer scope when programmatically constructing a Graph that will |
1145 | | - be used as a GraphProto attribute in another Node.. |
| 1160 | + be used as a GraphProto attribute in another Node. |
1146 | 1161 | e.g. when creating a Graph instance that will be used as a subgraph in a control flow operator, it is necessary to |
1147 | 1162 | define placeholder NodeArgs for outer scope values. This prevents these values from becoming explicit graph inputs |
1148 | 1163 | when the Graph is resolved. |
@@ -1391,6 +1406,13 @@ class Graph { |
1391 | 1406 | Node& AddNode(const ONNX_NAMESPACE::NodeProto& node_proto, |
1392 | 1407 | const ArgNameToTypeMap& name_to_type); |
1393 | 1408 |
|
| 1409 | + /** Helper that converts and adds constant node proto to an initializer in the graph. |
| 1410 | + @param constant_node_proto Constant node to convert |
| 1411 | + @param new_name use the new name for the initializer. |
| 1412 | + */ |
| 1413 | + Status AddConstantProtoAsInitializer(const ONNX_NAMESPACE::NodeProto& constant_node_proto, |
| 1414 | + std::optional<std::string_view> new_name); |
| 1415 | + |
1394 | 1416 | #endif |
1395 | 1417 |
|
1396 | 1418 | Version IrVersion() const noexcept { |
|
0 commit comments