CompiledStepHostValue<T>

Helpers & Utilities · AiDotNet.Training

A tensor a training forward computes on the host from other tensors of the same step (a data-dependent choice: the strongest autocorrelation lags, the most active queries), declared so that a compiled training plan recomputes it on every replay. No gradient flows through it.

How It Works

A compiled plan traces the forward once and replays the graph. A choice made on the host from the step’s values (read the scores, sort them, keep the top few) is not an engine op, so the trace keeps the first step’s answer as a constant and every later step reuses it: the model attends to step one’s queries, or aggregates step one’s lags, for the whole run. Nothing fails; the model trains on the wrong graph.

Computing the choice through this type records it as a node of the plan that reads its inputs’ current values and computes again on every replay, as it does eagerly. Use the result through ops that read their indices at run time (masks, matrix products, TensorEmbeddingLookupFromFloatIndices), never through an index tensor built on the host, which the trace would freeze in turn. Per-step random draws belong in CompiledStepRandom.

Methods

Method Summary
Tensor<T> Compute(string name, Tensor<T>[] inputs, int[] shape, Action<Tensor<T>[], Tensor<T>> compute) The tensor of shape that compute writes from the current values of inputs; under a compiled trace, a node that recomputes it on every replay.