coremlit 0.1.0

Safe, synchronous CoreML runtime for macOS (CPU/GPU/Neural Engine) with opt-in on-device multimodal pipelines: speech (Whisper STT, forced alignment, speaker diarization, Silero VAD), AudioSet sound-event tagging, and audio/text/image embeddings (CLAP, granite, SigLIP)
//! Safe, synchronous CoreML runtime layer.
//!
//! Wraps `objc2-core-ml` behind owned types: [`Model`] (load / compile /
//! prewarm / predict / stateful predict), [`MultiArray`] (typed N-d tensors,
//! including IOSurface-backed `f16`), and [`Features`] (named model I/O).
//! All `unsafe` FFI lives inside this crate; the public API is safe.
//!
//! macOS only. Mirrors the CoreML surface used by Argmax's WhisperKit
//! (`MLModelExtensions` / `MLMultiArrayExtensions` in argmax-oss-swift).
//!
//! That core is always compiled, and `default = []` pulls no pipeline
//! dependencies. The opt-in pipelines built on it are feature-gated submodules
//! of [`audio`] (`whisper`, `align`, `speaker`, `vad`, `ced`, `lid`) and
//! [`embeddings`] (`clap`, `granite`, `siglip`) — speech, sound-event tagging,
//! spoken-language identification, and audio/text/image embeddings
//! respectively.
//!
//! # Example
//!
//! ```no_run
//! use coremlit::{ComputeUnits, DataType, Features, Model, MultiArray};
//!
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let model = Model::load("MelSpectrogram.mlmodelc", ComputeUnits::CpuAndGpu)?;
//! let audio = MultiArray::zeros(&[480_000], DataType::F32)?;
//! let outputs = model.predict(&Features::new().with("audio", audio))?;
//! let mel = outputs.get("melspectrogram_features").unwrap();
//! assert_eq!(mel.data_type(), DataType::F16);
//! # Ok(())
//! # }
//! ```

mod dtype;
mod error;
mod features;
mod model;
mod multi_array;
mod state;
mod units;

pub use dtype::DataType;
pub use error::{
  AllocationFailed, CompileError, DataTypeMismatch, IndexOutOfBounds, LoadError, NonContiguous,
  NsErrorInfo, PredictionError, RankMismatch, ShapeMismatch, ShapeRequirement, TensorError,
  UnsupportedShape,
};
pub use features::Features;
/// Half-precision element type, re-exported for [`Element`] consumers.
pub use half::f16;
pub use model::{
  AxisRange, FeatureInfo, Model, ModelDescription, ShapeConstraint, UnmeasuredEnumeration,
};
pub use multi_array::{Element, MultiArray};
pub use state::State;
pub use units::{ComputeUnits, ParseComputeUnitsError};

pub mod audio;
pub mod embeddings;

// The in-lib model gates outnumber every `tests/` binary's put together, and a
// modelless run reports them as `ignored` and nothing else. See the module.
#[cfg(test)]
mod tests;