Skip to main content

tinyquant_core/
lib.rs

1//! CPU-only vector quantization codec — core types, codec, corpus, and
2//! backend trait.
3//!
4//! This crate is `no_std` (requires `alloc` only). It contains no I/O,
5//! no file-system access, and no platform-specific code.
6#![no_std]
7#![deny(
8    warnings,
9    missing_docs,
10    unsafe_op_in_unsafe_fn,
11    clippy::all,
12    clippy::pedantic,
13    clippy::nursery,
14    clippy::unwrap_used,
15    clippy::expect_used,
16    clippy::panic,
17    clippy::indexing_slicing,
18    clippy::cognitive_complexity
19)]
20#![allow(clippy::module_name_repetitions, clippy::must_use_candidate)]
21
22extern crate alloc;
23
24#[cfg(feature = "std")]
25extern crate std;
26
27pub mod backend;
28pub mod codec;
29pub mod corpus;
30pub mod errors;
31pub mod prelude;
32pub mod types;
33
34/// GPU acceleration trait and threshold constant.
35///
36/// # Why these are defined here (not re-exported from `tinyquant-gpu-wgpu`)
37///
38/// `tinyquant-gpu-wgpu` depends on `tinyquant-core`, so adding
39/// `tinyquant-gpu-wgpu` as an optional dependency of `tinyquant-core` would
40/// create a Cargo cyclic dependency (which Cargo rejects unconditionally).
41/// Therefore `GpuComputeBackend` and `GPU_BATCH_THRESHOLD` are defined
42/// directly in `tinyquant-core`. Concrete implementations (`WgpuBackend`)
43/// live in `tinyquant-gpu-wgpu` and implement `GpuComputeBackend`.
44pub mod gpu {
45    pub use crate::codec::service::{GpuComputeBackend, GPU_BATCH_THRESHOLD};
46}
47
48// Flat re-exports for ergonomic use without the `gpu` module prefix.
49/// The backend trait for GPU-accelerated compute operations.
50pub use crate::codec::service::GpuComputeBackend;
51
52/// Minimum batch size below which GPU offload is not attempted.
53pub use crate::codec::service::GPU_BATCH_THRESHOLD;