runtime_value#
RuntimeValue represents named TypeProto.struct_type fields and
EncodedValueProto payloads. Tensor leaves reuse Tensor. Ordinary tensor
edges remain exclusively in RuntimeContext::tensors(); values() is for
structured/encoded edges, not a parallel tensor store.
The header declares the representation and API; runtime_value.cc implements
copying, retention and validation.
The representation is independent of persistence. Encoded messages have one
immutable shared owner from construction, not mutable inline storage plus a
second promoted representation. BorrowView() copies numeric metadata and
existing owner handles, without changing the source. Ordinary string fields
are materialized instead, as required by normal string execution.
DeepCopy() copies all payloads explicitly.
std::move(value).Retain() consumes a selected whole result, recursively moving
owned tensor buffers or exporting existing I/O allocations as IOLease handles.
An ownerless borrow or unleased execution-arena allocation cannot be retained,
except an explicit immutable initializer view whose proto lifetime is guaranteed
by the C++ caller.
String tensors cannot be retained, including nested fields and constants in an
encoded layout. Retain(catalogue) resolves encoded layout references through
the model catalogue; unresolved references and recursive types are rejected.
Structured Identity forwarding uses normal RuntimeValue copy semantics:
owned tensor storage is copied, while existing tensor owners and immutable
encoded messages are shared. Unlike BorrowView(), this keeps inline-owned
intermediate fields valid when their source is released, including when there
are multiple consumers. It does not mutate or promote the source.
-
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 runtime
Typedefs
-
using RuntimeValueMap = std::unordered_map<std::string, RuntimeValue>#
-
class RuntimeSequence#
- #include <runtime_value.h>
Shares immutable sequence elements through a balanced tree.
Copies share metadata; append and replacement copy only a logarithmic path. Elements are read-only: replaces a changed element with Set(), never through a mutable reference. Retained payloads follow the usual read-only contract.
Public Functions
-
RuntimeSequence() = default#
-
explicit RuntimeSequence(std::vector<RuntimeValue> values)#
-
inline size_t size() const noexcept#
-
inline bool empty() const noexcept#
-
inline void clear() noexcept#
-
inline size_t depth() const noexcept#
-
inline bool retained() const noexcept#
-
const RuntimeValue &at(size_t index) const#
-
inline const RuntimeValue &operator[](size_t index) const#
-
inline const RuntimeValue &front() const#
-
inline const RuntimeValue &back() const#
-
void push_back(RuntimeValue value)#
-
void Set(size_t index, RuntimeValue value)#
Replaces an element without changing any existing snapshot.
-
RuntimeSequence Transform(const std::function<RuntimeValue(const RuntimeValue&)> &transform) const#
Returns a sequence with independently transformed elements.
-
void TransformInPlace(const std::function<void(RuntimeValue&)> &transform)#
Updates unpublished elements, consuming unique storage and copying shared snapshots.
-
inline const_iterator begin() const#
-
inline const_iterator end() const#
Private Functions
-
void Retain(const StructTypeCatalogue &catalogue, size_t depth)#
Private Static Functions
-
static Root RetainNode(const Root &root, const StructTypeCatalogue &catalogue, size_t depth)#
-
static Root TransformNode(const Root &root, const std::function<RuntimeValue(const RuntimeValue&)> &transform)#
-
static Root TransformOwnedNode(const Root &root, bool shared, const std::function<void(RuntimeValue&)> &transform)#
-
static const RuntimeValue &At(const Root &root, size_t index)#
Friends
- friend struct RuntimeValue
-
class const_iterator#
- #include <runtime_value.h>
Public Types
-
using value_type = RuntimeValue#
-
using reference = const RuntimeValue&#
-
using pointer = const RuntimeValue*#
Public Functions
-
const_iterator() = default#
-
inline const_iterator &operator++()#
-
inline const_iterator operator++(int)#
-
bool operator==(const const_iterator &other) const = default#
-
using value_type = RuntimeValue#
-
template<typename Result>
class Memo# - #include <runtime_value.h>
Memoizes one immutable analysis policy without retaining sequence storage.
Private Functions
Friends
- friend class RuntimeSequence
-
struct Entry#
-
struct Node#
-
RuntimeSequence() = default#
-
struct RuntimeValue#
- #include <runtime_value.h>
Represents tensors, typed sequences, named structures and immutable encoded proto values.
RuntimeContext stores ordinary tensor edges in its existing tensor map, not here. This recursive representation supplies the structured/encoded edges required by TypeProto, independently of whether an edge is persistent.
Public Types
Public Functions
-
RuntimeValue() = default#
-
inline explicit RuntimeValue(std::unordered_map<std::string, RuntimeValue> value)#
-
inline explicit RuntimeValue(std::vector<RuntimeValue> value)#
-
explicit RuntimeValue(EncodedValueProto value)#
-
bool HasPagedCacheStructure() const#
Recognizes the cache’s named structure; payloads and ranges require separate validation.
-
PagedCacheProto ToPagedCache(const std::string &name = "", const StructTypeCatalogue &catalogue = {}) const#
Exports a cache without decoding pages, sharing retained storage and copying ownerless payloads. Referenced types remain model-scoped.
-
const EncodedValueProto &Encoded() const#
Returns the immutable encoded message.
-
RuntimeValue BorrowView() const#
Borrows numeric storage and materializes ordinary string fields without changing this value.
-
RuntimeValue DeepCopy() const#
Returns independent owned payloads.
-
RuntimeValue Retain(const StructTypeCatalogue &catalogue = {}) &&#
Consumes a selected whole value and explicitly retains its backing storage.
Public Members
-
std::unordered_map<std::string, RuntimeValue> fields#
-
RuntimeSequence elements#
-
std::shared_ptr<const EncodedValueProto> encoded#
-
std::shared_ptr<const QuantizationParameterCatalogue> quantization_parameters#
Public Static Functions
Returns an immutable message view with an explicit lifetime owner.
-
static RuntimeValue FromEncodedView(const EncodedValueProto &value)#
Borrows immutable proto storage; the proto must outlive all returned views.
Restores a validated cache, retaining proto storage and any shared parameter catalogue.
Public Static Attributes
-
static constexpr size_t kMaxDepth = 64#
Private Functions
-
size_t Depth(size_t depth = 0) const#
-
bool CatalogueIndependent(size_t depth = 0) const#
-
void RetainAtDepth(size_t depth, const StructTypeCatalogue &catalogue)#
-
RuntimeValue CopyAtDepth(size_t depth, bool owned) const#
Friends
- friend class RuntimeSequence
-
RuntimeValue() = default#
-
using RuntimeValueMap = std::unordered_map<std::string, RuntimeValue>#
-
namespace runtime
-
namespace core