persistent_value_state#
Each call follows four steps:
Binds retained values to the declared persistent inputs and adds current feeds.
Runs the session, reusing eligible append buffers or allocating new ones.
Validates outputs and checks cancellation.
Publishes the selected outputs as the next state only on success.
Views share tensor data but keep separate names and shapes. In-place append writes only the new region; growth may copy the old prefix. Failure leaves the previous logical state unchanged.
Bindings#
model.graph.persistent_bindingsmaps whole outputs to next-call inputs. Each persistent input must have exactly one value-use.Names are literal:
request.cacheis a graph name, not a field path. Duplicate bindings and partial structured inputs are rejected.Current feeds cannot override retained inputs, even with an empty field map.
Values()uses input names; returned outputs use output names.Supported values are tensors, named structures and inline structured encodings. Persistent strings are rejected, including nested strings.
Ownership#
The model stays immutable; declarations are resolved once, without cloning it. A shared-model constructor or
model_ownerretains its lifetime. Otherwise, the caller keeps it alive through all exported model-backed views.initialandResettake maps by value in C++. Usestd::move(initial)to avoid copying owned payloads.Returned views share owners and remain valid after later calls, reset or close. Callers must not modify shared payloads; publication does not undo such writes.
Retained borrows need owners, and arena allocations need self-owning I/O leases. Unsafe storage is rejected, not copied as a fallback.
All calls use the same allocators, kept alive until the state closes.
RetainOwnercan retain model/context owners before execution, including failed attempts. Owners must not own the state itself.Model-backed initializer views retain the constructor’s model owner. Borrowed raw data additionally needs its own storage owner; ordinary kernel results cannot use the model owner to extend their lifetime.
Execution and lifecycle#
Execution uses the ordinary
RuntimeSessionand cached kernels. Only declared persistent outputs bypass normal output materialization.Ifand local functions transport selected outputs without payload copies. Other operators retain their ordinary computation and transport costs.Reset(initial)replaces retained values but keeps the prepared session.Close()releases retained values and kernels and permanently closes the state.Events use
context.events()whenevents_enabledis true, including work before failure.ClearEvents()clears this log, not the persistent values.
See Persistent input/output feedback for usage and storage details, and runtime_context.h for event fields.
Warning
doxygenfile: Cannot find file “onnx_core/runtime/persistent_value_state.h