graph_manipulations.h#
Lightweight GraphProto / NodeProto manipulation helpers (formerly
onnx_proto/common_functions.h), including
onnx_light::CollectExternalInputs(),
onnx_light::CollectRemainingInputs() and
onnx_light::CollectNodeInputs().
-
namespace onnx_light
Alias that makes onnx-light headers compatible with code that references
ONNX_LIGHT_NAMESPACE(the macro used in the standard onnx package).Set to
ONNX_LIGHT_NAMESPACEso both names resolve to the same namespace.Symbol-visibility attribute for the public onnx-light C++ API.
Defined as empty because onnx-light does not require explicit
__declspec(dllexport)or__attribute__((visibility("default")))annotations — visibility is controlled at the shared-library level. The macro is provided so that vendored ONNX headers that decorate their declarations withONNX_APIcompile without modification.Namespace alias so that ONNX C++ code (and consumers such as onnxruntime) that refers to the literal
onnxnamespace — rather than theONNX_NAMESPACEmacro — resolves to the onnx-light namespace. The standard onnx package lives innamespace onnx; onnx-light usesonnx_light(via ONNX_LIGHT_NAMESPACE), so this alias keeps onnx-light a true drop-in. It is only introduced when the onnx-light namespace differs fromonnx.Functions
-
std::vector<std::string> CollectExternalInputs(const utils::RepeatedProtoField<NodeProto> &nodes)#
Returns the list of input names referenced by
nodesthat are not produced as outputs by any node in the same list.Recursively inspects subgraph attributes (
GRAPH/GRAPHS) and appends names read by subgraph nodes when neither the subgraph nor the outernodesproduce those names.The returned list preserves first-seen order and contains no duplicates. Empty input names are skipped.
-
std::vector<std::string> CollectExternalInputs(const std::vector<NodeProto> &nodes)#
std::vectoroverload of :cpp:func:CollectExternalInputs.
-
std::vector<std::vector<std::string>> CollectRemainingInputs(const utils::RepeatedProtoField<NodeProto> &nodes, const std::vector<std::string> &outputs)#
Returns, for every node in
nodes, the list of input names that must already be available before that node runs in order to eventually produce the requestedoutputs.The algorithm performs a backward reachability analysis: starting from the requested
outputs, it determines the ancestors (the nodes and tensors the outputs transitively depend on). For each indexiit considers the suffixnodes[i..], keeps only the nodes of that suffix that are ancestors ofoutputs(branches that do not contribute tooutputsare pruned), and reports the names those relevant nodes read — including names captured by subgraph attributesGRAPH/GRAPHS— that are not produced within the suffix. Those are the tensors that need to be kept alive before running nodei.nodesis expected to be in topological order. The returned vector has exactlynodes.size()entries. Each inner list preserves first-seen order and contains no duplicates; empty input names are skipped.
-
std::vector<std::vector<std::string>> CollectRemainingInputs(const std::vector<NodeProto> &nodes, const std::vector<std::string> &outputs)#
std::vectoroverload of :cpp:func:CollectRemainingInputs.
-
std::vector<std::string> CollectNodeInputs(const NodeProto &node)#
Returns the full list of tensor / sequence names a single
nodedepends on at runtime.Includes names referenced by
node.input()and external inputs captured by subgraph attributes (GRAPH/GRAPHS), preserves first-seen order without duplicates, and skips empty input names.
-
std::vector<std::string> CollectExternalInputs(const utils::RepeatedProtoField<NodeProto> &nodes)#