result_lifetime.h#
Standalone value-lifetime analysis shared by :cpp:func:ComputeContext::ComputeInPlaceReuseGraph.
This header isolates the purely name-based bookkeeping that decides, for every node of a graph, which referenced values reach their last use at that node (:cpp:var:ResultLifetimeNodeInfo::release_after / :cpp:var:ResultLifetimeNodeInfo::not_used_after). It does not depend on shape inference or byte sizes: those live in compute_context.cc and combine this lifetime information with the shape-driven in-place reuse matching.
-
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.
Maps the upstream compatibility macro to onnx-light’s explicit proto ABI annotation. This keeps declarations from vendored ONNX headers visible when
lib_onnx_protouses hidden visibility by default.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.-
namespace core
-
namespace compute
Functions
-
ResultLifetimeInfo ComputeResultLifetimeInfo(const GraphProto &graph, bool allow_input_overwrite)#
Computes the per-node value-lifetime information for
graph: which values are read for the last time at each node, and which of those are releasable top-level intermediates versus caller-owned inputs / initializers.- Parameters:
graph – Graph whose nodes are analysed, in topological order.
allow_input_overwrite – When true, declared graph inputs are treated as available before the first node (producer index
-1) so they can be reused once they reach their last use; when false they are always kept alive.
-
class ResultLifetimeInfo#
- #include <result_lifetime.h>
Result of :cpp:func:
ComputeResultLifetimeInfo: a per-node list of :cpp:struct:ResultLifetimeNodeInfoplus the producer / lifetime maps and name sets it was derived from, so callers can reuse them without recomputing.Public Types
-
using value_type = ResultLifetimeNodeInfo#
-
using storage_type = std::vector<value_type>#
-
using iterator = storage_type::iterator#
-
using const_iterator = storage_type::const_iterator#
Public Functions
-
inline bool empty() const#
-
inline value_type &operator[](std::size_t index)#
-
inline const value_type &operator[](std::size_t index) const#
-
inline const_iterator begin() const#
-
inline const_iterator end() const#
-
inline const_iterator cbegin() const#
-
inline const_iterator cend() const#
Public Members
-
std::unordered_map<std::string, int> producer#
Producer node index for every top-level intermediate (
-1marks a declared graph input made available before the first node whenallow_input_overwriteis set).
-
std::unordered_map<std::string, int> last_use#
Index of the last node that references each name, directly or through a subgraph capture.
Private Members
-
storage_type nodes_#
-
using value_type = ResultLifetimeNodeInfo#
-
struct ResultLifetimeNodeInfo#
- #include <result_lifetime.h>
Holds per-node value-lifetime bookkeeping from :cpp:func:
ComputeResultLifetimeInfo.
-
ResultLifetimeInfo ComputeResultLifetimeInfo(const GraphProto &graph, bool allow_input_overwrite)#
-
namespace compute
-
namespace core