candle_coreml/
lib.rs

1pub mod builder;
2pub mod builtin_configs;
3pub mod clean_git_lfs_downloader;
4pub mod config;
5pub mod conversion;
6#[cfg(test)]
7pub mod infer_shape_test;
8pub mod model;
9pub mod model_config;
10pub mod model_downloader;
11pub mod pipeline;
12pub mod qwen;
13#[cfg(test)]
14pub mod qwen_shapes_test;
15pub mod state;
16pub mod utils;
17
18pub use builder::CoreMLModelBuilder;
19pub use builtin_configs::{get_builtin_config, list_builtin_models};
20pub use config::Config;
21pub use model::CoreMLModel;
22pub use model_config::{ComponentConfig, ModelConfig, NamingConfig, ShapeConfig, TensorConfig};
23pub use qwen::{ModelNamingConfig, QwenConfig, QwenModel};
24pub use state::CoreMLState;
25
26// Main unified downloader API (recommended)
27pub use model_downloader::{
28    download_model, download_model_to, ensure_model_downloaded, get_cached_model_path,
29};
30
31// Advanced downloader API (for specific use cases)
32pub use clean_git_lfs_downloader::{
33    download_hf_model_clean, verify_download_completeness, CleanDownloadConfig,
34};
35
36// Shared utilities for transformer models
37pub use utils::{mask, multi_component, sampling};
38
39use std::path::PathBuf;
40
41/// Helper function to get a file locally first, then download from `HuggingFace` Hub if needed.
42/// Follows the same pattern as quantized-t5 example.
43pub fn get_local_or_remote_file(
44    filename: &str,
45    api: &hf_hub::api::sync::ApiRepo,
46) -> anyhow::Result<PathBuf> {
47    let local_filename = PathBuf::from(filename);
48    if local_filename.exists() {
49        Ok(local_filename)
50    } else {
51        Ok(api.get(filename)?)
52    }
53}