ImmutableDatasetWriter#
- class torchrl.data.replay_buffers.ImmutableDatasetWriter(compilable: bool = False)[source]#
A blocking writer for immutable datasets.
- add(data: Any) int[source]#
Inserts one piece of data at an appropriate index, and returns that index.
- extend(data: Sequence) Tensor[source]#
Inserts a series of data points at appropriate indices, and returns a tensor containing the indices.
- generations_of(index: int | Tensor) Tensor#
Returns the generation stamp for each physical slot in
index.A slot’s stamp advances once per write it receives, so a single
extendthat wraps the storage advances a reused slot once per write. Comparing a stamp captured at sampling time against the current stamp tells you whether the slot still holds the data you sampled.Writers that do not track slot reuse – and writers constructed with
track_generations=False, which is the default – report-1everywhere. Never-written slots also report-1, so-1means “no usable stamp” rather than “generation zero”.- Parameters:
index (int or torch.Tensor) – dim-0 slot indices. A 1-D tensor is always read as a batch of slot indices; for a storage with
ndim > 1, pass atupleof per-dimension indices (asextend()returns) to identify a single cell – only its dim-0 component is used, since a generation stamps a whole dim-0 slot.- Returns:
int64stamps shaped like the dim-0 component ofindex, onindex’s device.- Return type:
- tracks_generations: bool = False#
Whether this writer stamps storage slots with a reuse generation. Always
Falseunless the writer both supports generation tracking and was constructed with it enabled (seeRoundRobinWriter).