Skip to main content

HostDataset

Trait HostDataset 

Source
pub trait HostDataset: Send + Sync {
    // Required methods
    fn len(&self) -> i64;
    fn get_host_sample(&self, index: i64) -> Result<HostSample>;

    // Provided method
    fn is_empty(&self) -> bool { ... }
}
Expand description

Thread-shareable host dataset contract for PrefetchDataLoader.

Runtime is !Send, so async prefetch runs on host values: worker threads index a HostDataset, collate host-side, and the consumer thread uploads each batch to the device — the same split as DataLoader(num_workers>0, pin_memory=True) in torch, where workers also produce host tensors.

Required Methods§

Source

fn len(&self) -> i64

Total number of items in the dataset.

Source

fn get_host_sample(&self, index: i64) -> Result<HostSample>

Retrieve one host sample by index.

§Errors

Returns an error for an out-of-range index or a failed read.

Provided Methods§

Source

fn is_empty(&self) -> bool

Return true when the dataset contains no items.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§