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§
Sourcefn get_host_sample(&self, index: i64) -> Result<HostSample>
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§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".