sensorlm/lib.rs
1//! # sensorlm-rs
2//!
3//! A complete Rust implementation of the **SensorLM** sensor-language foundation
4//! model (NeurIPS 2025) using the [Burn](https://burn.dev) deep-learning framework.
5//!
6//! ## Backend selection
7//!
8//! By default this crate uses the **NdArray** (CPU) backend. Enable the WGPU
9//! (GPU) backend by building with the `wgpu` feature:
10//!
11//! ```bash
12//! cargo build --features wgpu
13//! ```
14//!
15//! ## Architecture overview
16//!
17//! ```text
18//! ┌────────────────────────────────────────┐
19//! Raw wearable data │ SensorLM (Two-Tower) │
20//! (1440 × 34 × 1) │ │
21//! │ │ ┌──────────────┐ SigLIP loss │
22//! ▼ │ │ SensorEncoder│──────────────────┐ │
23//! Normalise / mask │ │ (ViT-B/10/2)│ │ │
24//! │ │ │ MAP pooling │ │ │
25//! │ │ └──────────────┘ contrastive │ │
26//! │ │ 768-dim alignment │ │
27//! │ │ ▼ │
28//! Caption pipeline ──▶ │ ┌──────────────┐ ┌─────────────────┐│
29//! (stat/struct/semantic)│ │ TextEncoder │ │ temperature ││
30//! │ │ (Transformer│ │ + bias scalars ││
31//! │ │ 12 layers) │ └─────────────────┘│
32//! │ └──────────────┘ │
33//! └────────────────────────────────────────┘
34//! ```
35
36#![warn(missing_docs, rustdoc::missing_crate_level_docs)]
37
38pub mod config;
39pub mod constants;
40pub mod data;
41pub mod error;
42pub mod inference;
43pub mod loss;
44pub mod model;
45pub mod quantization;
46pub mod training;
47
48// ---------------------------------------------------------------------------
49// Backend type aliases
50// ---------------------------------------------------------------------------
51
52/// NdArray (CPU) backend for inference and testing.
53pub type CpuBackend = burn::backend::NdArray;
54
55/// Autodiff wrapper over NdArray for CPU training / unit tests.
56pub type CpuTrainBackend = burn::backend::Autodiff<CpuBackend>;
57
58// WGPU backend aliases (only available with `wgpu` feature).
59#[cfg(feature = "wgpu")]
60/// WGPU backend for GPU inference (no autodiff).
61pub type WgpuBackend = burn::backend::Wgpu;
62
63#[cfg(feature = "wgpu")]
64/// Autodiff wrapper over WGPU for GPU training.
65pub type TrainBackend = burn::backend::Autodiff<WgpuBackend>;