pub trait BatchDataSet: Send + Sync {
// Required methods
fn len(&self) -> usize;
fn get_batch(&self, indices: &[usize]) -> Result<Vec<Tensor>>;
// Provided method
fn is_empty(&self) -> bool { ... }
}Expand description
A dataset that provides entire batches at once.
Implement this when your storage can produce a batch more efficiently than N individual gets (e.g., contiguous memory-mapped arrays, database bulk reads, or pre-stacked tensors).
DataSet is automatically promoted to BatchDataSet via
DataSetAdapter (call get() N times and stack position-wise).
Requires Send + Sync for background prefetch (see DataSet docs).
§Contract
Each tensor in the returned Vec must have dimension 0 as the batch
dimension, with length equal to indices.len(). The number of tensors
and their shapes (beyond dim 0) must be consistent across calls.