Skip to main content

Module data_source

Module data_source 

Source
Expand description

bb::DataSource — Contract trait for data loaders.

Each method takes the engine’s &mut RuntimeResourceRef<'_> ctx plus a CompletionHandle AND returns ContractResponse. See crate::contracts::index for the sync (Now) vs async (Later) semantics.

ctx exposes ctx.dependency::<T>("<slot>") for the source to reach any concrete declared in #[depends(...)] (e.g. a Backend to materialize the batch tensor on-device).

§Associated type: Sample

Sample is the element type for both the batch tensor and the optional labels tensor returned by DataSource::next_batch. Implement as [f32] for flat f32 sample batches. The second slot (Box<Self::Sample>) holds labels; unsupervised sources return a zero-length boxed slice.

Traits§

DataSource
User-facing Contract trait for a data source / data loader.