HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
onnxruntime::GraphViewer Class Reference

#include <graph_viewer.h>

Public Member Functions

 GraphViewer (const Graph &graph)
 
 GraphViewer (const Graph &graph, const IndexedSubGraph &filter_info)
 
const std::stringName () const noexcept
 
const std::stringDescription () const noexcept
 
const Path & ModelPath () const noexcept
 
bool GetInitializedTensor (const std::string &tensor_name, const ONNX_NAMESPACE::TensorProto *&value) const
 
bool CanOverrideInitializer () const noexcept
 
const std::vector< const
NodeArg * > & 
GetInputs () const noexcept
 
const std::vector< const
NodeArg * > & 
GetInputsIncludingInitializers () const noexcept
 
const std::vector< const
NodeArg * > & 
GetOutputs () const noexcept
 
bool NodeProducesGraphOutput (const Node &node) const
 
const std::unordered_set
< const NodeArg * > & 
GetValueInfo () const noexcept
 
const NodeGetNode (NodeIndex node_index) const
 
const ConstGraphNodesNodes () const noexcept
 
int NumberOfNodes () const noexcept
 
int MaxNodeIndex () const noexcept
 
const std::vector< NodeIndex > & GetNodesInTopologicalOrder (ExecutionOrder order=ExecutionOrder::DEFAULT) const
 
const std::vector< NodeIndex > & GetRootNodes () const
 
const InitializedTensorSetGetAllInitializedTensors () const noexcept
 
const NodeArgGetNodeArg (const std::string &name) const
 
const std::unordered_map
< std::string, int > & 
DomainToVersionMap () const noexcept
 
bool IsSubgraph () const
 
const GraphGetGraph () const
 
const std::unordered_set
< std::string > & 
GetOuterScopeNodeArgNames () const noexcept
 
bool IsConstantInitializer (const std::string &name, bool check_outer_scope) const
 
bool IsInitializedTensor (const std::string &name) const
 
const ONNX_NAMESPACE::TensorProto * GetConstantInitializer (const std::string &name, bool check_outer_scope) const
 
const NodeParentNode () const noexcept
 
std::vector< const Node * > GetConsumerNodes (const std::string &node_arg_name) const
 
const NodeGetProducerNode (const std::string &node_arg_name) const
 
const IndexedSubGraphGetFilterInfo () const
 
IOnnxRuntimeOpSchemaCollectionPtr GetSchemaRegistry () const
 

Detailed Description

Class that provides a read-only view of the Graph.

Remarks
If the underlying Graph is changed, GetNodesInTopologicalOrder and GetRootNodes may become invalid.

Definition at line 27 of file graph_viewer.h.

Constructor & Destructor Documentation

onnxruntime::GraphViewer::GraphViewer ( const Graph graph)
explicit

Construct a GraphViewer from the provided Graph instance.

onnxruntime::GraphViewer::GraphViewer ( const Graph graph,
const IndexedSubGraph filter_info 
)
explicit

Construct a GraphViewer from the provided Graph instance, filtering to the nodes specified in the IndexedSubGraph

Member Function Documentation

bool onnxruntime::GraphViewer::CanOverrideInitializer ( ) const
noexcept

Returns true if an initializer value can be overridden by a graph input with the same name.

const std::string& onnxruntime::GraphViewer::Description ( ) const
noexcept

Gets the Graph description.

const std::unordered_map<std::string, int>& onnxruntime::GraphViewer::DomainToVersionMap ( ) const
inlinenoexcept

Gets the map of operator domains to their opset versions.

Definition at line 136 of file graph_viewer.h.

const InitializedTensorSet& onnxruntime::GraphViewer::GetAllInitializedTensors ( ) const
noexcept

Gets all tensors created from initializers.

const ONNX_NAMESPACE::TensorProto* onnxruntime::GraphViewer::GetConstantInitializer ( const std::string name,
bool  check_outer_scope 
) const

returns the initializer's TensorProto if 'name' is an initializer, is constant and cannot be overridden at runtime. If the initializer is not found or is not constant, a nullptr is returned.

Parameters
check_outer_scopeIf true and the graph is a subgraph, check ancestor graph/s for 'name' if not found in 'graph'.
Remarks
This function will return the result from GetConstantInitializer of the underlying Graph, if a const initializer is part of the underlying Graph but not part of this GraphViewer, it will still be returned instead of nullptr
std::vector<const Node*> onnxruntime::GraphViewer::GetConsumerNodes ( const std::string node_arg_name) const
inline

Get the consumer nodes of a node arg

Definition at line 175 of file graph_viewer.h.

const IndexedSubGraph* onnxruntime::GraphViewer::GetFilterInfo ( ) const
inline

Get the filter info that restricts the graph viewer to a subset of nodes if set.

Returns
Filter info or nullptr

Definition at line 188 of file graph_viewer.h.

const Graph& onnxruntime::GraphViewer::GetGraph ( ) const
inline

Get the internal graph

Definition at line 144 of file graph_viewer.h.

bool onnxruntime::GraphViewer::GetInitializedTensor ( const std::string tensor_name,
const ONNX_NAMESPACE::TensorProto *&  value 
) const

Gets a tensor created from an initializer.

Parameters
tensor_nameThe tensor name
[out]valueSets the pointer to the TensorProto if found, or nullptr if not.
Returns
True if found. False if not.
const std::vector<const NodeArg*>& onnxruntime::GraphViewer::GetInputs ( ) const
noexcept

Gets the Graph inputs, excluding initializers.

Returns
Collection of NodeArg pointers for the graph inputs, excluding inputs that have matching initializers.
Remarks
No nullptr values in the returned collection. The order will be the same as in the GraphProto. Inputs are for filter_info_ if set.
const std::vector<const NodeArg*>& onnxruntime::GraphViewer::GetInputsIncludingInitializers ( ) const
noexcept

Gets the Graph inputs, including any initializers.

Returns
Collection of NodeArg pointers for all the graph inputs.
Remarks
No nullptr values in the returned collection. The order will be the same as in the GraphProto. Inputs are for filter_info_ if set.
const Node* onnxruntime::GraphViewer::GetNode ( NodeIndex  node_index) const

Gets the Node instance at the specified index.

Parameters
node_indexIndex to retrieve Node from.
Remarks
May return nullptr if index no longer points to a valid node due to the node being freed, or if node is excluded by filter_info_.
const NodeArg* onnxruntime::GraphViewer::GetNodeArg ( const std::string name) const

Gets the NodeArg instance for the given name.

Returns
A NodeArg if found, a nullptr if not.
const std::vector<NodeIndex>& onnxruntime::GraphViewer::GetNodesInTopologicalOrder ( ExecutionOrder  order = ExecutionOrder::DEFAULT) const

Gets the NodeIndex values for the Graph nodes, sorted into topological order.

Remarks
Filtered using filter_info_ if set.
const std::unordered_set<std::string>& onnxruntime::GraphViewer::GetOuterScopeNodeArgNames ( ) const
noexcept
const std::vector<const NodeArg*>& onnxruntime::GraphViewer::GetOutputs ( ) const
noexcept

Gets the Graph outputs.

Returns
Collection of NodeArg pointers for all the graph outputs.
Remarks
No nullptr values in the returned collection. The order will be the same as in the GraphProto. Outputs are for filter_info_ if set.
const Node* onnxruntime::GraphViewer::GetProducerNode ( const std::string node_arg_name) const
inline

Get the producer node of a node arg

Definition at line 180 of file graph_viewer.h.

const std::vector<NodeIndex>& onnxruntime::GraphViewer::GetRootNodes ( ) const

Gets the NodeIndex values for the root nodes in the Graph. The root nodes are the topmost nodes in the Graph that receive inputs from the Graph inputs and no other nodes in the Graph.

Remarks
Not supported if filter_info_ is set.
IOnnxRuntimeOpSchemaCollectionPtr onnxruntime::GraphViewer::GetSchemaRegistry ( ) const
inline

Definition at line 191 of file graph_viewer.h.

const std::unordered_set<const NodeArg*>& onnxruntime::GraphViewer::GetValueInfo ( ) const
noexcept

Gets all ValueInfo NodeArg instances in the Graph.

Remarks
NOT filtered using filter_info_.
bool onnxruntime::GraphViewer::IsConstantInitializer ( const std::string name,
bool  check_outer_scope 
) const

returns true if 'name' is an initializer, and is constant and cannot be overridden at runtime.

Parameters
check_outer_scopeIf true and the 'graph_' is a subgraph, check parent graph/s for 'name' if the name is not found in 'graph_'.
bool onnxruntime::GraphViewer::IsInitializedTensor ( const std::string name) const

Check if a given name is an initializer tensor's name in this graph.

bool onnxruntime::GraphViewer::IsSubgraph ( ) const

Checks if this is a Subgraph

int onnxruntime::GraphViewer::MaxNodeIndex ( ) const
noexcept

Gets the maximum NodeIndex value used by Nodes in the Graph.

const Path& onnxruntime::GraphViewer::ModelPath ( ) const
inlinenoexcept

Gets the path of the owning model if any

Definition at line 46 of file graph_viewer.h.

const std::string& onnxruntime::GraphViewer::Name ( ) const
noexcept

Gets the Graph name.

bool onnxruntime::GraphViewer::NodeProducesGraphOutput ( const Node node) const

Returns true if one or more of the Node outputs are Graph outputs.

const ConstGraphNodes& onnxruntime::GraphViewer::Nodes ( ) const
noexcept

Gets an iterator over all the valid Nodes in the Graph.

Remarks
Nodes are filtered using filter_info_ if set.
int onnxruntime::GraphViewer::NumberOfNodes ( ) const
noexcept

Gets the number of valid nodes in the Graph.

Remarks
Returns the number of nodes in filter_info_ if set.
const Node* onnxruntime::GraphViewer::ParentNode ( ) const
inlinenoexcept

Get the Node containing this Graph if IsSubgraph is true. Returns nullptr otherwise.

Definition at line 171 of file graph_viewer.h.


The documentation for this class was generated from the following file: