| |
| |
|
|
| #pragma once |
|
|
| #include <limits> |
| #include <memory> |
| #include <string> |
| #include <type_traits> |
| #include <unordered_map> |
| #include <unordered_set> |
|
|
| #ifdef _WIN32 |
| #pragma warning(push) |
| |
| #pragma warning(disable : 4244) |
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| #include "onnx/defs/schema.h" |
| #include "core/common/inlined_containers.h" |
| #else |
| #include "onnx/defs/data_type_utils.h" |
| #endif |
| #include "onnx/onnx_pb.h" |
| #include "onnx/onnx-operators_pb.h" |
|
|
| #ifdef _WIN32 |
| #pragma warning(pop) |
| #endif |
|
|
| #include "core/common/gsl.h" |
|
|
| #include "core/common/common.h" |
| #include "core/common/const_pointer_container.h" |
| #include "core/common/inlined_containers_fwd.h" |
| #include "core/common/path.h" |
| #include "core/common/span_utils.h" |
| #include "core/common/status.h" |
| #include "core/common/logging/logging.h" |
| #include "core/graph/basic_types.h" |
| #include "core/graph/constants.h" |
| #include "core/graph/function.h" |
| #if !defined(ORT_MINIMAL_BUILD) |
| #include "core/graph/function_template.h" |
| #endif |
| #include "core/graph/graph_nodes.h" |
| #include "core/graph/node_arg.h" |
| #include "core/graph/ort_format_load_options.h" |
|
|
| namespace flatbuffers { |
| class FlatBufferBuilder; |
| template <typename T> |
| struct Offset; |
| } |
|
|
| namespace onnxruntime { |
| class Graph; |
| struct IndexedSubGraph; |
| class Model; |
| class OpSignature; |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| class RuntimeOptimizationRecordContainer; |
| #endif |
|
|
| namespace fbs { |
| struct Graph; |
| struct Node; |
| struct NodeEdge; |
| } |
|
|
| |
| |
| |
| |
| class Node { |
| public: |
| |
| enum class Type { |
| Primitive = 0, |
| Fused = 1, |
| }; |
|
|
| explicit Node() = default; |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| Node(std::string_view name, |
| std::string_view op_type, |
| std::string_view description, |
| gsl::span<NodeArg* const> input_args, |
| gsl::span<NodeArg* const> output_args, |
| const NodeAttributes* attributes, |
| std::string_view domain) { |
| Init(std::string{name}, std::string{op_type}, std::string{description}, |
| std::vector<NodeArg*>{input_args.begin(), input_args.end()}, |
| std::vector<NodeArg*>{output_args.begin(), output_args.end()}, |
| attributes, std::string{domain}); |
| } |
| #endif |
|
|
| ~Node() = default; |
|
|
| |
| |
| |
| |
| |
| |
| class EdgeEnd { |
| public: |
| |
| |
| |
| |
| |
| |
| |
| EdgeEnd(const Node& node, int src_arg_index, int dst_arg_index) noexcept; |
|
|
| |
| |
| |
| explicit EdgeEnd(const Node& node) noexcept; |
|
|
| |
| const Node& GetNode() const noexcept { return *node_; } |
|
|
| |
| |
| int GetSrcArgIndex() const { return src_arg_index_; } |
|
|
| |
| |
| int GetDstArgIndex() const { return dst_arg_index_; } |
|
|
| private: |
| const Node* node_; |
| const int src_arg_index_; |
| const int dst_arg_index_; |
| }; |
|
|
| |
| NodeIndex Index() const noexcept { return index_; } |
|
|
| |
| const std::string& Name() const noexcept { return name_; } |
|
|
| |
| const std::string& OpType() const noexcept { return op_type_; } |
|
|
| |
| |
| |
| const std::string& Domain() const noexcept { return domain_; } |
|
|
| |
| const Path& ModelPath() const noexcept; |
|
|
| |
| |
| int Priority() const noexcept { return priority_; }; |
|
|
| |
| |
| void SetPriority(int priority) noexcept; |
|
|
| |
| const std::string& Description() const noexcept { return description_; } |
|
|
| |
| Node::Type NodeType() const noexcept { return node_type_; } |
|
|
| |
| |
| |
| |
| int SinceVersion() const noexcept { return since_version_; } |
|
|
| |
| |
| |
| |
| void SetSinceVersion(int since_version) noexcept { since_version_ = since_version; } |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| |
| const ONNX_NAMESPACE::OpSchema* Op() const noexcept { return op_; } |
|
|
| |
| bool TryGetFunctionProto(ONNX_NAMESPACE::FunctionProto& func_proto) const; |
|
|
| bool CanBeInlined() const; |
|
|
| |
| const Function* GetFunctionBody() const noexcept { return func_body_.get(); } |
| #endif |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| static common::Status ForEachWithIndex(const ConstPointerContainer<std::vector<NodeArg*>>& node_args, |
| std::function<common::Status(const NodeArg& arg, size_t index)> func) { |
| for (size_t index = 0; index < node_args.size(); ++index) { |
| auto arg = node_args[index]; |
| if (!arg->Exists()) |
| continue; |
| ORT_RETURN_IF_ERROR(func(*arg, index)); |
| } |
| return common::Status::OK(); |
| } |
|
|
| |
| const std::vector<int>& InputArgCount() const noexcept { return definitions_.input_arg_count; } |
|
|
| |
| |
| ConstPointerContainer<std::vector<NodeArg*>> InputDefs() const noexcept { |
| return ConstPointerContainer<std::vector<NodeArg*>>(definitions_.input_defs); |
| } |
|
|
| |
| |
| |
| ConstPointerContainer<std::vector<NodeArg*>> ImplicitInputDefs() const noexcept { |
| return ConstPointerContainer<std::vector<NodeArg*>>(definitions_.implicit_input_defs); |
| } |
|
|
| |
| |
| ConstPointerContainer<std::vector<NodeArg*>> OutputDefs() const noexcept { |
| return ConstPointerContainer<std::vector<NodeArg*>>(definitions_.output_defs); |
| } |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| |
| |
| |
| |
| |
| |
| |
| static common::Status ForEachMutableWithIndex(std::vector<NodeArg*>& node_args, |
| std::function<common::Status(NodeArg& arg, size_t index)> func) { |
| for (size_t index = 0; index < node_args.size(); ++index) { |
| auto arg = node_args[index]; |
| if (!arg->Exists()) |
| continue; |
| ORT_RETURN_IF_ERROR(func(*arg, index)); |
| } |
| return common::Status::OK(); |
| } |
|
|
| |
| std::vector<NodeArg*>& MutableImplicitInputDefs() noexcept { |
| return definitions_.implicit_input_defs; |
| } |
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| |
| |
| |
| std::vector<int>& MutableInputArgsCount() { return definitions_.input_arg_count; } |
|
|
| |
| std::vector<NodeArg*>& MutableInputDefs() noexcept { |
| return definitions_.input_defs; |
| } |
|
|
| |
| std::vector<NodeArg*>& MutableOutputDefs() noexcept { |
| return definitions_.output_defs; |
| } |
| #endif |
|
|
| |
| struct EdgeEndCompare { |
| bool operator()(const EdgeEnd& lhs, const EdgeEnd& rhs) const { |
| if (lhs.GetNode().Index() == rhs.GetNode().Index()) { |
| if (lhs.GetSrcArgIndex() == rhs.GetSrcArgIndex()) { |
| return lhs.GetDstArgIndex() < rhs.GetDstArgIndex(); |
| } |
| return lhs.GetSrcArgIndex() < rhs.GetSrcArgIndex(); |
| } |
| return lhs.GetNode().Index() < rhs.GetNode().Index(); |
| } |
| }; |
|
|
| using EdgeSet = std::set<EdgeEnd, EdgeEndCompare>; |
| using EdgeConstIterator = EdgeSet::const_iterator; |
|
|
| |
| |
| |
| class NodeConstIterator { |
| public: |
| NodeConstIterator(EdgeConstIterator p_iter); |
|
|
| bool operator==(const NodeConstIterator& p_other) const; |
|
|
| bool operator!=(const NodeConstIterator& p_other) const; |
|
|
| void operator++(); |
| void operator--(); |
|
|
| const Node& operator*() const; |
| const Node* operator->() const; |
|
|
| private: |
| EdgeConstIterator m_iter; |
| }; |
|
|
| |
|
|
| |
| NodeConstIterator InputNodesBegin() const noexcept { return NodeConstIterator(relationships_.input_edges.cbegin()); }; |
| |
| NodeConstIterator InputNodesEnd() const noexcept { return NodeConstIterator(relationships_.input_edges.cend()); } |
|
|
| |
| NodeConstIterator OutputNodesBegin() const noexcept { |
| return NodeConstIterator(relationships_.output_edges.cbegin()); |
| } |
|
|
| |
| NodeConstIterator OutputNodesEnd() const noexcept { return NodeConstIterator(relationships_.output_edges.cend()); } |
|
|
| |
| |
| EdgeConstIterator InputEdgesBegin() const noexcept { return relationships_.input_edges.cbegin(); } |
|
|
| |
| EdgeConstIterator InputEdgesEnd() const noexcept { return relationships_.input_edges.cend(); } |
|
|
| |
| |
| EdgeConstIterator OutputEdgesBegin() const noexcept { return relationships_.output_edges.cbegin(); } |
|
|
| |
| EdgeConstIterator OutputEdgesEnd() const noexcept { return relationships_.output_edges.cend(); } |
|
|
| |
| const std::set<std::string>& ControlInputs() const noexcept { return relationships_.control_inputs; } |
|
|
| |
| size_t GetInputEdgesCount() const noexcept { return relationships_.input_edges.size(); } |
|
|
| |
| size_t GetOutputEdgesCount() const noexcept { return relationships_.output_edges.size(); } |
|
|
| |
| |
| void AddAttributeProto(ONNX_NAMESPACE::AttributeProto value); |
|
|
| |
| |
| void AddAttribute(std::string attr_name, int64_t value); |
|
|
| |
| |
| void AddAttribute(std::string attr_name, gsl::span<const int64_t> values); |
|
|
| #define ADD_ATTR_SINGLE_INTERFACE(Type) \ |
| void AddAttribute(std::string attr_name, Type value) |
|
|
| #define ADD_ATTR_LIST_INTERFACE(Type) \ |
| void AddAttribute(std::string attr_name, gsl::span<const Type> values) |
|
|
| #define ADD_ATTR_INTERFACES(Type) \ |
| ADD_ATTR_SINGLE_INTERFACE(Type); \ |
| ADD_ATTR_LIST_INTERFACE(Type) |
|
|
| ADD_ATTR_INTERFACES(float); |
| ADD_ATTR_INTERFACES(std::string); |
| ADD_ATTR_INTERFACES(ONNX_NAMESPACE::TensorProto); |
| #if !defined(DISABLE_SPARSE_TENSORS) |
| ADD_ATTR_INTERFACES(ONNX_NAMESPACE::SparseTensorProto); |
| #endif |
| ADD_ATTR_INTERFACES(ONNX_NAMESPACE::TypeProto); |
|
|
| ADD_ATTR_SINGLE_INTERFACE(ONNX_NAMESPACE::GraphProto); |
|
|
| #undef ADD_ATTR_SINGLE_INTERFACE |
| #undef ADD_ATTR_LIST_INTERFACE |
| #undef ADD_ATTR_INTERFACES |
|
|
| |
| |
| template <size_t N> |
| void AddAttribute(std::string attr_name, const char (&value)[N]) { |
| this->AddAttribute(std::move(attr_name), std::string(value, N - 1)); |
| } |
|
|
| |
| const NodeAttributes& GetAttributes() const noexcept { return attributes_; } |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| |
| bool ClearAttribute(const std::string& attr_name); |
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| NodeAttributes& GetMutableAttributes() noexcept { return attributes_; } |
|
|
| |
| |
| |
| |
| const Graph* GetGraphAttribute(const std::string& attr_name) const; |
|
|
| |
| |
| |
| |
| Graph* GetMutableGraphAttribute(const std::string& attr_name); |
| #endif |
|
|
| |
| |
| |
| bool ContainsSubgraph() const { |
| return !attr_to_subgraph_map_.empty(); |
| } |
|
|
| |
| |
| std::vector<gsl::not_null<const Graph*>> GetSubgraphs() const; |
|
|
| |
| |
| |
| |
| const std::unordered_map<std::string, gsl::not_null<Graph*>>& GetAttributeNameToMutableSubgraphMap() { |
| return attr_to_subgraph_map_; |
| } |
|
|
| |
| |
| |
| |
| std::unordered_map<std::string, gsl::not_null<const Graph*>> GetAttributeNameToSubgraphMap() const; |
|
|
| |
| ProviderType GetExecutionProviderType() const noexcept { return execution_provider_type_; } |
|
|
| |
| void SetExecutionProviderType(ProviderType execution_provider_type) { |
| execution_provider_type_ = execution_provider_type; |
| } |
|
|
| |
| |
| |
| |
| |
| void ForEachDef(std::function<void(const onnxruntime::NodeArg&, bool is_input)> func, |
| bool include_missing_optional_defs = false) const; |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| |
| |
| void ReplaceDefs(const std::map<const onnxruntime::NodeArg*, onnxruntime::NodeArg*>& replacements); |
|
|
| |
| |
| |
| |
| |
| void ToProto(ONNX_NAMESPACE::NodeProto& proto, bool update_subgraphs = false) const; |
|
|
| Status SaveToOrtFormat(flatbuffers::FlatBufferBuilder& builder, |
| flatbuffers::Offset<onnxruntime::fbs::Node>& fbs_node) const; |
|
|
| flatbuffers::Offset<onnxruntime::fbs::NodeEdge> |
| SaveEdgesToOrtFormat(flatbuffers::FlatBufferBuilder& builder) const; |
|
|
| void SetFunctionTemplate(const FunctionTemplate& func_template); |
| #endif |
|
|
| static Status LoadFromOrtFormat(const onnxruntime::fbs::Node& fbs_node, Graph& graph, |
| const OrtFormatLoadOptions& load_options, |
| const logging::Logger& logger, std::unique_ptr<Node>& node); |
|
|
| Status LoadFromOrtFormat(const onnxruntime::fbs::Node& fbs_node, |
| const OrtFormatLoadOptions& load_options, |
| const logging::Logger& logger); |
| Status LoadEdgesFromOrtFormat(const onnxruntime::fbs::NodeEdge& fbs_node_edgs, const Graph& graph); |
|
|
| |
| |
| |
| |
| class Definitions { |
| public: |
| Definitions() = default; |
|
|
| |
| std::vector<NodeArg*> input_defs; |
|
|
| |
| |
| |
| |
| |
| |
| std::vector<int> input_arg_count; |
|
|
| |
| std::vector<NodeArg*> output_defs; |
|
|
| |
| |
| |
| |
| |
| std::vector<NodeArg*> implicit_input_defs; |
|
|
| ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Definitions); |
|
|
| private: |
| }; |
|
|
| |
| |
| |
| |
| class Relationships { |
| public: |
| Relationships() = default; |
|
|
| void Clear() noexcept { |
| input_edges.clear(); |
| output_edges.clear(); |
| control_inputs.clear(); |
| } |
|
|
| |
| EdgeSet input_edges; |
|
|
| |
| EdgeSet output_edges; |
|
|
| |
| std::set<std::string> control_inputs; |
|
|
| private: |
| ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Relationships); |
| }; |
|
|
| |
| |
| friend class Graph; |
| Node(NodeIndex index, Graph& graph) : index_(index), graph_(&graph) {} |
|
|
| private: |
| ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Node); |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| void Init(const std::string& name, |
| const std::string& op_type, |
| const std::string& description, |
| const std::vector<NodeArg*>& input_args, |
| const std::vector<NodeArg*>& output_args, |
| const NodeAttributes* attributes, |
| const std::string& domain); |
|
|
| |
| Definitions& MutableDefinitions() noexcept; |
|
|
| |
| Relationships& MutableRelationships() noexcept; |
|
|
| void SetNodeType(Node::Type node_type) noexcept { node_type_ = node_type; } |
| #endif |
|
|
| |
| void CreateSubgraph(const std::string& attr_name); |
|
|
| const std::vector<std::unique_ptr<Graph>>& MutableSubgraphs() noexcept { return subgraphs_; } |
|
|
| |
| common::Status UpdateInputArgCount(); |
|
|
| const Definitions& GetDefinitions() const noexcept { return definitions_; } |
| const Relationships& GetRelationships() const noexcept { return relationships_; } |
|
|
| |
| NodeIndex index_ = std::numeric_limits<NodeIndex>::max(); |
|
|
| |
| std::string name_; |
|
|
| |
| std::string op_type_; |
|
|
| |
| std::string domain_; |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| const ONNX_NAMESPACE::OpSchema* op_ = nullptr; |
|
|
| |
| const FunctionTemplate* func_template_ = nullptr; |
| #endif |
|
|
| |
| int priority_ = 0; |
|
|
| |
| int since_version_ = -1; |
|
|
| Node::Type node_type_ = Node::Type::Primitive; |
|
|
| |
| std::unique_ptr<Function> func_body_ = nullptr; |
|
|
| |
| std::string description_; |
|
|
| |
| Definitions definitions_; |
|
|
| |
| Relationships relationships_; |
|
|
| |
| std::string execution_provider_type_; |
|
|
| |
| |
| NodeAttributes attributes_; |
|
|
| |
| Graph* graph_ = nullptr; |
|
|
| |
| std::unordered_map<std::string, gsl::not_null<Graph*>> attr_to_subgraph_map_; |
|
|
| |
| std::vector<std::unique_ptr<Graph>> subgraphs_; |
| }; |
|
|
| |
| |
| |
| |
| |
| class Graph { |
| public: |
| |
| const std::string& Name() const noexcept; |
|
|
| |
| const std::string& Description() const noexcept; |
|
|
| |
| const Path& ModelPath() const; |
|
|
| |
| bool IsSubgraph() const { return parent_graph_ != nullptr; } |
|
|
| |
| const Graph* ParentGraph() const { return parent_graph_; } |
|
|
| |
| Graph* MutableParentGraph() { return parent_graph_; } |
|
|
| |
| bool StrictShapeTypeInference() const { return strict_shape_type_inference_; } |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| void SetName(const std::string& name); |
|
|
| |
| void SetDescription(const std::string& description); |
|
|
| |
| |
| |
| |
| |
| |
| common::Status ReplaceInitializedTensor(ONNX_NAMESPACE::TensorProto new_initializer); |
|
|
| #if !defined(DISABLE_EXTERNAL_INITIALIZERS) |
| |
| |
| |
| common::Status InjectExternalInitializedTensors(const InlinedHashMap<std::string, OrtValue>& external_initializers); |
| #endif |
|
|
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| |
| void AddInitializedTensor(const ONNX_NAMESPACE::TensorProto& tensor_proto); |
| #endif |
|
|
| |
| void RemoveInitializedTensor(const std::string& tensor_name); |
|
|
| |
| bool IsInitializedTensor(const std::string& name) const; |
|
|
| #if !defined(DISABLE_SPARSE_TENSORS) |
| |
| |
| |
| |
| bool IsSparseInitializer(const std::string& name) const; |
| #endif |
|
|
| |
| |
| |
| |
| bool GetInitializedTensor(const std::string& tensor_name, const ONNX_NAMESPACE::TensorProto*& value) const; |
|
|
| |
| const InitializedTensorSet& GetAllInitializedTensors() const noexcept { return name_to_initial_tensor_; } |
|
|
| |
| void CleanAllInitializedTensors() noexcept; |
|
|
| |
| bool CanOverrideInitializer() const noexcept { return ir_version_ >= 4; } |
|
|
| |
| |
| |
| |
| |
| |
| const ONNX_NAMESPACE::TensorProto* GetConstantInitializer(const std::string& name, bool check_outer_scope) const; |
|
|
| |
| |
| |
| |
| |
| |
| const ONNX_NAMESPACE::TensorProto* GetInitializer(const std::string& name, bool check_outer_scope) const; |
|
|
| |
| |
| |
| const std::vector<const NodeArg*>& GetInputs() const noexcept { return graph_inputs_excluding_initializers_; } |
|
|
| |
| |
| |
| const std::vector<const NodeArg*>& GetInputsIncludingInitializers() const noexcept { |
| return graph_inputs_including_initializers_; |
| } |
|
|
| |
| bool IsInputsIncludingInitializers(const NodeArg* node_arg) const noexcept { |
| return std::find(graph_inputs_including_initializers_.begin(), |
| graph_inputs_including_initializers_.end(), node_arg) != graph_inputs_including_initializers_.end(); |
| } |
|
|
| |
| |
| |
| |
| const std::vector<const NodeArg*>& GetOverridableInitializers() const { |
| return graph_overridable_initializers_; |
| } |
|
|
| |
| |
| const std::vector<const NodeArg*>& GetOutputs() const noexcept { return graph_outputs_; } |
|
|
| bool IsOutput(const NodeArg* node_arg) const noexcept { |
| return std::find(graph_outputs_.begin(), graph_outputs_.end(), node_arg) != graph_outputs_.end(); |
| } |
|
|
| |
| |
| |
| bool NodeProducesGraphOutput(const Node& node) const { |
| auto end_outputs = graph_outputs_.cend(); |
| for (auto output_def : node.OutputDefs()) { |
| if (std::find(graph_outputs_.cbegin(), end_outputs, output_def) != end_outputs) { |
| return true; |
| } |
| } |
| return false; |
| } |
|
|
| |
| std::vector<int> GetNodeOutputsInGraphOutputs(const Node& node) const { |
| int output_idx = 0; |
| std::vector<int> indexes; |
| for (auto output_def : node.OutputDefs()) { |
| if (std::find(GetOutputs().cbegin(), GetOutputs().cend(), output_def) != GetOutputs().cend()) { |
| indexes.push_back(output_idx); |
| } |
|
|
| ++output_idx; |
| } |
|
|
| return indexes; |
| } |
|
|
| |
| |
| |
| const std::unordered_set<const NodeArg*>& GetValueInfo() const noexcept { return value_info_; } |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| void AddValueInfo(const NodeArg* new_value_info); |
| #endif |
|
|
| |
| |
| |
| const Node* GetNode(NodeIndex node_index) const { return NodeAtIndexImpl(node_index); } |
|
|
| |
| |
| |
| Node* GetNode(NodeIndex node_index) { return NodeAtIndexImpl(node_index); } |
|
|
| |
| GraphNodes& Nodes() noexcept { return iterable_nodes_; } |
|
|
| |
| const GraphNodes& Nodes() const noexcept { return iterable_nodes_; } |
|
|
| |
| |
| |
| |
| |
| ConstGraphNodes FilteredNodes(GraphNodes::NodeFilterFunc&& filter_func) const noexcept { |
| return ConstGraphNodes(nodes_, std::move(filter_func)); |
| } |
|
|
| |
| |
| |
| int MaxNodeIndex() const noexcept { return static_cast<int>(nodes_.size()); } |
|
|
| |
| |
| |
| int NumberOfNodes() const noexcept { return num_of_nodes_; } |
|
|
| |
| |
| NodeArg* GetNodeArg(const std::string& name) { |
| auto iter = node_args_.find(name); |
| if (iter != node_args_.end()) { |
| return iter->second.get(); |
| } |
| return nullptr; |
| } |
|
|
| |
| |
| const NodeArg* GetNodeArg(const std::string& name) const { |
| return const_cast<Graph*>(this)->GetNodeArg(name); |
| } |
|
|
| |
| NodeArg* GetNodeArgIncludingParentGraphs(const std::string& node_arg_name); |
|
|
| |
| |
| |
| |
| |
| NodeArg& GetOrCreateNodeArg(const std::string& name, const ONNX_NAMESPACE::TypeProto* p_arg_type) { |
| auto iter = node_args_.find(name); |
| if (iter != node_args_.end()) { |
| return *(iter->second); |
| } |
| auto result = node_args_.insert(std::make_pair(name, std::make_unique<NodeArg>(name, p_arg_type))); |
| return *(result.first->second); |
| } |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| |
| std::string GenerateNodeArgName(const std::string& base_name); |
|
|
| |
| std::string GenerateNodeName(const std::string& base_name); |
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| |
| |
| |
| |
| Node& AddNode(const Node& other); |
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| Node& AddNode(const std::string& name, |
| const std::string& op_type, |
| const std::string& description, |
| gsl::span<NodeArg* const> input_args, |
| gsl::span<NodeArg* const> output_args, |
| const NodeAttributes* attributes = nullptr, |
| const std::string& domain = kOnnxDomain); |
|
|
| Node& AddNode(const std::string& name, |
| const std::string& op_type, |
| const std::string& description, |
| std::initializer_list<NodeArg*> input_args, |
| std::initializer_list<NodeArg*> output_args, |
| const NodeAttributes* attributes = nullptr, |
| const std::string& domain = kOnnxDomain) { |
| return AddNode(name, op_type, description, |
| AsSpan(input_args), |
| AsSpan(output_args), |
| attributes, domain); |
| } |
|
|
| Node& AddNode(const std::string& name, |
| const std::string& op_type, |
| const std::string& description, |
| gsl::span<NodeArg* const> input_args, |
| std::initializer_list<NodeArg*> output_args, |
| const NodeAttributes* attributes = nullptr, |
| const std::string& domain = kOnnxDomain) { |
| return AddNode(name, op_type, description, |
| input_args, |
| AsSpan(output_args), |
| attributes, domain); |
| } |
|
|
| Node& AddNode(const std::string& name, |
| const std::string& op_type, |
| const std::string& description, |
| std::initializer_list<NodeArg*> input_args, |
| gsl::span<NodeArg* const> output_args, |
| const NodeAttributes* attributes = nullptr, |
| const std::string& domain = kOnnxDomain) { |
| return AddNode(name, op_type, description, |
| AsSpan(input_args), |
| output_args, |
| attributes, domain); |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| bool RemoveNode(NodeIndex node_index); |
|
|
| |
| |
| |
| |
| |
| |
| void AddEdge(NodeIndex src_node_index, NodeIndex dst_node_index, int src_arg_index, int dst_arg_index); |
|
|
| |
| |
| |
| |
| |
| |
| void RemoveEdge(NodeIndex src_node_index, NodeIndex dst_node_index, int src_arg_index, int dst_arg_index); |
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| |
| |
| |
| |
| bool AddControlEdge(NodeIndex src_node_index, NodeIndex dst_node_index); |
| #endif |
|
|
| |
| |
| Graph& SetGraphResolveNeeded() noexcept { |
| graph_resolve_needed_ = true; |
| return *this; |
| } |
|
|
| |
| bool GraphResolveNeeded() const noexcept { |
| return graph_resolve_needed_; |
| } |
|
|
| |
| Graph& SetGraphProtoSyncNeeded() noexcept { |
| graph_proto_sync_needed_ = true; |
| return *this; |
| } |
|
|
| |
| bool GraphProtoSyncNeeded() const noexcept { |
| return graph_proto_sync_needed_; |
| } |
|
|
| |
| |
| |
| |
| |
| |
| |
| void ReverseDFSFrom(gsl::span<NodeIndex const> from, |
| const std::function<void(const Node*)>& enter, |
| const std::function<void(const Node*)>& leave, |
| const std::function<bool(const Node*, const Node*)>& comp = {}) const; |
|
|
| |
| |
| |
| |
| |
| |
| |
| void ReverseDFSFrom(gsl::span<const Node* const> from, |
| const std::function<void(const Node*)>& enter, |
| const std::function<void(const Node*)>& leave, |
| const std::function<bool(const Node*, const Node*)>& comp = {}) const; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| void ReverseDFSFrom(gsl::span<const Node* const> from, |
| const std::function<void(const Node*)>& enter, |
| const std::function<void(const Node*)>& leave, |
| const std::function<bool(const Node*, const Node*)>& comp, |
| const std::function<bool(const Node*, const Node*)>& stop) const; |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| |
| |
| |
| void KahnsTopologicalSort(const std::function<void(const Node*)>& enter, |
| const std::function<bool(const Node*, const Node*)>& comp) const; |
|
|
| #endif |
|
|
| |
| const std::unordered_map<std::string, int>& DomainToVersionMap() const noexcept { |
| return domain_to_version_; |
| } |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| Node& BeginFuseSubGraph(const IndexedSubGraph& sub_graph, const std::string& fused_node_name); |
|
|
| void FinalizeFuseSubGraph(const IndexedSubGraph& sub_graph, Node& fused_node); |
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| const ONNX_NAMESPACE::GraphProto& ToGraphProto(); |
| ONNX_NAMESPACE::GraphProto ToGraphProto() const; |
|
|
| |
| |
| |
| |
| |
| |
| ONNX_NAMESPACE::GraphProto ToGraphProtoWithExternalInitializers(const std::string& external_file_name, |
| size_t initializer_size_threshold) const; |
|
|
| |
| IOnnxRuntimeOpSchemaCollectionPtr GetSchemaRegistry() const; |
|
|
| |
| |
| |
| |
| |
| bool SetOpSchemaFromRegistryForNode(Node& node); |
|
|
| |
| |
| |
| |
| |
| |
| |
| Node& FuseSubGraph(const IndexedSubGraph& sub_graph, const std::string& fused_node_name); |
|
|
| |
| |
| |
| |
| |
| Status InlineFunction(Node& node); |
|
|
| |
| |
| |
| |
| |
| |
| void AddOuterScopeNodeArg(const std::string& name) { |
| ORT_IGNORE_RETURN_VALUE(outer_scope_node_arg_names_.insert(name)); |
| } |
|
|
| |
| |
| |
| |
| void SetInputs(gsl::span<const NodeArg* const> inputs); |
|
|
| void SetInputs(std::initializer_list<const NodeArg*> inputs) { |
| SetInputs(AsSpan(inputs)); |
| } |
|
|
| const Model& GetModel() const { |
| return owning_model_; |
| } |
|
|
| const logging::Logger& GetLogger() const { |
| return logger_; |
| } |
|
|
| |
| |
| |
| |
| void SetOutputs(gsl::span<const NodeArg* const> outputs); |
|
|
| void SetOutputs(std::initializer_list<const NodeArg*> outputs) { |
| SetOutputs(AsSpan(outputs)); |
| } |
|
|
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| |
| void SetNodeArgType(NodeArg& arg, const ONNX_NAMESPACE::TypeProto& type_proto); |
|
|
| const Node* GetProducerNode(const std::string& node_arg_name) const { |
| return GetProducerNodeImpl(*this, node_arg_name); |
| } |
|
|
| Node* GetMutableProducerNode(const std::string& node_arg_name) { |
| return GetProducerNodeImpl(*this, node_arg_name); |
| } |
|
|
| void UpdateProducerNode(const std::string& node_arg_name, NodeIndex node_index) { |
| auto iter = node_arg_to_producer_node_.find(node_arg_name); |
|
|
| if (iter != node_arg_to_producer_node_.end()) { |
| iter->second = node_index; |
| } else { |
| node_arg_to_producer_node_[node_arg_name] = node_index; |
| } |
| } |
|
|
| std::vector<const Node*> GetConsumerNodes(const std::string& node_arg_name) const { |
| return GetConsumerNodesImpl(*this, node_arg_name); |
| } |
|
|
| |
| void AddConsumerNode(const std::string& node_arg_name, Node* consumer) { |
| node_arg_to_consumer_nodes_[node_arg_name].insert(consumer->Index()); |
| } |
|
|
| |
| void RemoveConsumerNode(const std::string& node_arg_name, Node* consumer) { |
| node_arg_to_consumer_nodes_[node_arg_name].erase(consumer->Index()); |
| } |
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| std::vector<Node*> GetMutableConsumerNodes(const std::string& node_arg_name) { |
| return GetConsumerNodesImpl(*this, node_arg_name); |
| } |
|
|
| void UpdateConsumerNodes(const std::string& node_arg_name, gsl::span<Node* const> nodes) { |
| |
| auto& nodes_for_arg = node_arg_to_consumer_nodes_[node_arg_name]; |
| if (!nodes_for_arg.empty()) { |
| nodes_for_arg.clear(); |
| } |
|
|
| nodes_for_arg.reserve(nodes.size()); |
| for (Node* node : nodes) { |
| nodes_for_arg.insert(node->Index()); |
| } |
| } |
|
|
| void UpdateConsumerNodes(const std::string& node_arg_name, std::initializer_list<Node*> nodes) { |
| UpdateConsumerNodes(node_arg_name, AsSpan(nodes)); |
| } |
|
|
| |
| |
| |
| Status UpdateShapeInference(Node& node); |
|
|
| |
| struct ResolveOptions { |
| |
| bool override_types = false; |
| |
| const std::unordered_set<std::string>* initializer_names_to_preserve = nullptr; |
| |
| |
| bool no_proto_sync_required = false; |
| }; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| common::Status Resolve(const ResolveOptions& options); |
|
|
| common::Status Resolve() { |
| ResolveOptions default_options; |
| return Resolve(default_options); |
| } |
|
|
| const std::unordered_set<std::string>& GetOuterScopeNodeArgNames() const noexcept { |
| return outer_scope_node_arg_names_; |
| } |
|
|
| common::Status SaveToOrtFormat(flatbuffers::FlatBufferBuilder& builder, |
| flatbuffers::Offset<onnxruntime::fbs::Graph>& fbs_graph) const; |
|
|
| #endif |
|
|
| |
| const Node* ParentNode() const { return parent_node_; } |
|
|
| |
| bool IsOuterScopeValue(const std::string& name) const { |
| if (!parent_node_) return false; |
| const auto& implicit_input_defs = parent_node_->ImplicitInputDefs(); |
| return std::any_of(implicit_input_defs.cbegin(), implicit_input_defs.cend(), |
| [&name](const NodeArg* implicit_input) { |
| return implicit_input->Name() == name; |
| }); |
| } |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| |
| |
| |
| |
| |
| Graph(Graph& parent_graph, const Node& parent_node, ONNX_NAMESPACE::GraphProto& subgraph_proto); |
|
|
| Graph(const Model& owning_model, |
| IOnnxRuntimeOpSchemaCollectionPtr schema_registry, |
| ONNX_NAMESPACE::GraphProto& subgraph_proto, |
| const std::unordered_map<std::string, int>& domain_version_map, |
| const logging::Logger& logger, |
| bool strict_shape_type_inference); |
| #endif |
|
|
| virtual ~Graph(); |
|
|
| static Status LoadFromOrtFormat(const onnxruntime::fbs::Graph& fbs_graph, const Model& owning_model, |
| const std::unordered_map<std::string, int>& domain_to_version, |
| #if !defined(ORT_MINIMAL_BUILD) |
| IOnnxRuntimeOpSchemaCollectionPtr schema_registry, |
| #endif |
| const OrtFormatLoadOptions& load_options, |
| const logging::Logger& logger, std::unique_ptr<Graph>& graph); |
|
|
| |
| static Status LoadFromOrtFormat(const onnxruntime::fbs::Graph& fbs_graph, |
| Graph& parent_graph, const Node& parent_node, |
| const OrtFormatLoadOptions& load_options, |
| const logging::Logger& logger, std::unique_ptr<Graph>& graph); |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| const RuntimeOptimizationRecordContainer& RuntimeOptimizations() const { |
| return runtime_optimizations_; |
| } |
|
|
| RuntimeOptimizationRecordContainer& MutableRuntimeOptimizations() { |
| return runtime_optimizations_; |
| } |
| #endif |
|
|
| |
| |
| friend class Model; |
|
|
| Graph() = delete; |
|
|
| |
| Graph(const Model& owning_model, |
| const std::unordered_map<std::string, int>& domain_to_version, |
| #if !defined(ORT_MINIMAL_BUILD) |
| IOnnxRuntimeOpSchemaCollectionPtr schema_registry, |
| #endif |
| Graph* parent_graph, const Node* parent_node, |
| const logging::Logger& logger, |
| bool strict_shape_type_inference); |
|
|
| |
| Status LoadFromOrtFormat(const onnxruntime::fbs::Graph& fbs_graph, |
| const OrtFormatLoadOptions& load_options); |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| |
| Graph(const Model& owning_model, |
| ONNX_NAMESPACE::GraphProto* graph_proto, |
| const std::unordered_map<std::string, int>& domain_to_version, |
| Version ir_version, |
| IOnnxRuntimeOpSchemaCollectionPtr schema_registry, |
| const logging::Logger& logger, |
| bool strict_shape_type_inference); |
|
|
| |
| Graph(const Model& owning_model, |
| ONNX_NAMESPACE::GraphProto* graph_proto, |
| const std::unordered_map<std::string, int>& domain_to_version, |
| Version ir_version, |
| IOnnxRuntimeOpSchemaCollectionPtr schema_registry, |
| Graph* parent_graph, |
| const Node* parent_node, |
| const logging::Logger& logger, |
| bool strict_shape_type_inference); |
|
|
| ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(Graph); |
|
|
| private: |
| void InitializeStateFromModelFileGraphProto(); |
|
|
| |
| Node& AddNode(const ONNX_NAMESPACE::NodeProto& node_proto, |
| const ArgNameToTypeMap& name_to_type); |
|
|
| #endif |
|
|
| Version IrVersion() const noexcept { |
| return ir_version_; |
| } |
|
|
| Graph& GraphResolveNeeded(bool needed) noexcept { |
| graph_resolve_needed_ = needed; |
| return *this; |
| } |
|
|
| Graph& GraphProtoSyncNeeded(bool needed) noexcept { |
| graph_proto_sync_needed_ = needed; |
| return *this; |
| } |
|
|
| |
| |
| |
| |
| |
| struct ResolveContext { |
| ResolveContext(const Graph& owning_graph) : graph{owning_graph} { |
| } |
|
|
| std::unordered_map<std::string_view, std::pair<Node*, int>> output_args; |
| std::unordered_set<std::string_view> inputs_and_initializers; |
| std::unordered_map<std::string_view, NodeIndex> node_name_to_index; |
| std::unordered_set<Node*> nodes_with_subgraphs; |
|
|
| |
| |
| bool IsLocalValue(const std::string& name) const; |
|
|
| |
| |
| bool IsOuterScopeValue(const std::string& name) const; |
|
|
| void Clear() { |
| output_args.clear(); |
| inputs_and_initializers.clear(); |
| node_name_to_index.clear(); |
| nodes_with_subgraphs.clear(); |
| } |
|
|
| private: |
| bool IsInputInitializerOrOutput(const std::string& name, bool check_ancestors) const; |
|
|
| const Graph& graph; |
| ORT_DISALLOW_COPY_ASSIGNMENT_AND_MOVE(ResolveContext); |
| }; |
|
|
| |
| common::Status InitInputsInitializersOutputs(); |
|
|
| |
| void ComputeOverridableInitializers(); |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| |
| common::Status BuildConnections(std::unordered_set<std::string>& outer_scope_node_args_consumed); |
|
|
| common::Status VerifyNoDuplicateName(); |
|
|
| |
| |
| |
| |
| common::Status PerformTopologicalSortAndCheckIsAcyclic(); |
|
|
| common::Status PerformTypeAndShapeInferencing(const ResolveOptions& options); |
|
|
| |
| void FindAllSubgraphs(std::vector<Graph*>& subgraphs); |
|
|
| |
| common::Status ForThisAndAllSubgraphs(const std::vector<Graph*>& subgraphs, std::function<Status(Graph&)> func); |
|
|
| common::Status InferAndVerifyTypeMatch(Node& node, const ONNX_NAMESPACE::OpSchema& op, const ResolveOptions& options); |
|
|
| |
| static common::Status InferAndVerifySubgraphTypes(const Node& node, Graph& subgraph, |
| const std::vector<const ONNX_NAMESPACE::TypeProto*>& input_types, |
| std::vector<const ONNX_NAMESPACE::TypeProto*>& output_types, |
| const Graph::ResolveOptions& options); |
|
|
| |
| common::Status TypeCheckInputsAndInitializers(); |
|
|
| |
| common::Status VerifyInputAndInitializerNames(); |
|
|
| |
| |
|
|
| common::Status VerifyNodeAndOpMatch(const ResolveOptions& options); |
|
|
| |
| common::Status SetGraphInputsOutputs(); |
|
|
| |
| |
| common::Status SetOuterScopeNodeArgs(const std::unordered_set<std::string>& outer_scope_node_args); |
|
|
| |
| Status ReplaceInitializedTensorImpl(ONNX_NAMESPACE::TensorProto new_initializer, bool is_external); |
|
|
| |
| void CleanUnusedInitializersAndNodeArgs(const std::unordered_set<std::string>* initializer_names_to_preserve = nullptr); |
|
|
| std::vector<NodeArg*> CreateNodeArgs(const google::protobuf::RepeatedPtrField<std::string>& names, |
| const ArgNameToTypeMap& name_to_type_map); |
|
|
| void ToGraphProtoInternal(ONNX_NAMESPACE::GraphProto& graph_proto) const; |
|
|
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| Status PopulateNodeArgToProducerConsumerLookupsFromNodes(); |
|
|
| template <typename TInstance> |
| static auto GetConsumerNodesImpl( |
| TInstance& instance, const std::string& node_arg_name) -> std::vector<decltype(instance.GetNode(0))> { |
| std::vector<decltype(instance.GetNode(0))> results; |
| auto iter = instance.node_arg_to_consumer_nodes_.find(node_arg_name); |
| if (iter != instance.node_arg_to_consumer_nodes_.end()) { |
| results.reserve(iter->second.size()); |
| for (auto node_index : iter->second) { |
| results.push_back(instance.GetNode(node_index)); |
| } |
| } |
| return results; |
| } |
|
|
| template <typename TInstance> |
| static auto GetProducerNodeImpl( |
| TInstance& instance, const std::string& node_arg_name) -> decltype(instance.GetNode(0)) { |
| auto iter = instance.node_arg_to_producer_node_.find(node_arg_name); |
| if (iter != instance.node_arg_to_producer_node_.end()) { |
| auto node_index = iter->second; |
| return instance.GetNode(node_index); |
| } |
| return nullptr; |
| } |
|
|
| gsl::not_null<Node*> AllocateNode(); |
|
|
| |
| |
| bool ReleaseNode(NodeIndex node_index); |
|
|
| Node& CreateFusedSubGraphNode(const IndexedSubGraph& sub_graph, const std::string& fused_node_name); |
| #endif |
|
|
| Node* NodeAtIndexImpl(NodeIndex node_index) const { |
| |
| |
| |
| |
| ORT_ENFORCE(node_index < nodes_.size(), "Validating no unexpected access using an invalid node_index. Got:", |
| node_index, " Max:", nodes_.size()); |
| return nodes_[node_index].get(); |
| } |
|
|
| const Model& owning_model_; |
|
|
| |
| |
| |
| |
| |
| ONNX_NAMESPACE::GraphProto* graph_proto_; |
|
|
| |
| ONNX_NAMESPACE::GraphProto deserialized_proto_data_; |
|
|
| InitializedTensorSet name_to_initial_tensor_; |
|
|
| std::unordered_set<std::reference_wrapper<const std::string>, |
| std::hash<std::string>, std::equal_to<std::string>> |
| sparse_tensor_names_; |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| |
| |
| std::unique_ptr<RuntimeOptimizationRecordContainer> runtime_optimizations_ptr_; |
| RuntimeOptimizationRecordContainer& runtime_optimizations_; |
| #endif |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| IOnnxRuntimeOpSchemaCollectionPtr schema_registry_; |
|
|
| |
| |
| |
| InlinedVector<std::unique_ptr<ONNX_NAMESPACE::OpSchema>> fused_schemas_containers_; |
| |
| |
| InlinedHashMap<std::string, std::reference_wrapper<ONNX_NAMESPACE::OpSchema>> reusable_fused_schema_map_; |
| #endif |
|
|
| |
| |
| std::vector<std::unique_ptr<Node>> nodes_; |
|
|
| |
| GraphNodes iterable_nodes_{nodes_}; |
|
|
| |
| |
| |
| |
| int num_of_nodes_ = 0; |
|
|
| |
| bool graph_resolve_needed_ = false; |
|
|
| bool graph_proto_sync_needed_ = false; |
|
|
| |
| std::vector<NodeIndex> nodes_in_topological_order_; |
|
|
| |
| std::vector<const NodeArg*> graph_inputs_including_initializers_; |
| bool graph_inputs_manually_set_ = false; |
|
|
| |
| std::vector<const NodeArg*> graph_inputs_excluding_initializers_; |
|
|
| |
| |
| std::vector<const NodeArg*> graph_overridable_initializers_; |
|
|
| |
| std::vector<const NodeArg*> graph_outputs_; |
| bool graph_outputs_manually_set_ = false; |
|
|
| |
| std::unordered_set<const NodeArg*> value_info_; |
|
|
| |
| std::unordered_map<std::string, std::unique_ptr<NodeArg>> node_args_; |
|
|
| #if !defined(ORT_MINIMAL_BUILD) || defined(ORT_EXTENDED_MINIMAL_BUILD) |
| int name_generator_ = 0; |
|
|
| |
| |
| std::unordered_set<std::string> generated_node_names_; |
|
|
| |
| |
| std::unordered_set<std::string> generated_node_arg_names_; |
|
|
| |
| std::unordered_map<std::string, NodeIndex> node_arg_to_producer_node_; |
|
|
| |
| std::unordered_map<std::string, std::unordered_set<NodeIndex>> node_arg_to_consumer_nodes_; |
| #endif |
|
|
| const std::unordered_map<std::string, int> domain_to_version_; |
|
|
| |
| Version ir_version_{ONNX_NAMESPACE::Version::IR_VERSION}; |
|
|
| ResolveContext resolve_context_{*this}; |
|
|
| |
| Graph* parent_graph_; |
| |
| const Node* parent_node_; |
|
|
| |
| |
| std::unordered_set<std::string> outer_scope_node_arg_names_; |
|
|
| |
| int num_resolves_ = 0; |
|
|
| const logging::Logger& logger_; |
|
|
| |
| |
| |
| |
| const bool strict_shape_type_inference_; |
|
|
| |
| const bool is_loaded_from_model_file_; |
| }; |
|
|
| #if !defined(ORT_MINIMAL_BUILD) |
| |
| |
| |
| |
| std::ostream& operator<<(std::ostream& out, const NodeArg& node_arg); |
| |
| |
| |
| |
| std::ostream& operator<<(std::ostream& out, const Node& node); |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| std::ostream& operator<<(std::ostream& out, const Graph& graph); |
| #endif |
|
|
| } |
|
|