candle_coreml/
lib.rs

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