Skip to main content

load_auto

Function load_auto 

Source
pub fn load_auto<M: DeserializeOwned>(
    path: impl AsRef<Path>,
    expected_type: ModelType,
) -> Result<M>
Expand description

Load a model with automatic strategy selection based on file size

Toyota Way Principle: Heijunka (Level Loading) - Chooses the optimal loading strategy based on file size to balance memory and performance.

§Strategy

  • Files ≤ 1MB: Standard load() (lower overhead for small files)
  • Files > 1MB: Memory-mapped load_mmap() (better for large files)

§Example

use aprender::format::{load_auto, ModelType};

// Automatically chooses best loading strategy
let model: KMeans = load_auto("model.apr", ModelType::KMeans)?;

§Errors

Returns error on file not found, format error, type mismatch, or checksum failure