1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! # Ferrotensor - GPU-Accelerated Machine Learning Library
//!
//! A PyTorch-style tensor and neural-network API in pure Rust. Tensors live
//! on a [`Device`]: a GPU through wgpu (Metal, Vulkan, DX12) with hand-written
//! WGSL kernels, or the CPU, which needs no GPU and runs the same ops.
//!
//! ## Features
//!
//! - **Tensors**: broadcasting element-wise math, reductions over any dim,
//! batched matmul, softmax/log-softmax, permute, slicing, concatenation,
//! gathers.
//! - **Automatic differentiation**: every op records its backward pass;
//! gradients are checked against finite differences on the CPU and
//! against the CPU on the GPU.
//! - **`nn`**: Linear, Embedding, LayerNorm, RMSNorm, Dropout, multi-head
//! (causal) attention, activations, Sequential.
//! - **`optim`**: SGD (momentum, Nesterov), AdamW, gradient clipping,
//! warmup + cosine and other LR schedules.
//! - **`serialize`**: safetensors save/load and module state dicts.
//!
//! ## Quick Start
//!
//! ```rust
//! use ferrotensor::prelude::*;
//!
//! let device = Device::cpu(); // or Device::best() for a GPU when present
//! let model = nn::Sequential::new(&device)
//! .add(nn::Linear::new(2, 16, &device))
//! .add(nn::Tanh)
//! .add(nn::Linear::new(16, 2, &device));
//! let mut opt = optim::AdamW::new(model.parameters(), 0.05).weight_decay(0.0);
//!
//! // XOR
//! let x = Tensor::from_data(&[0., 0., 0., 1., 1., 0., 1., 1.], &[4, 2], &device);
//! let y = Tensor::from_data(&[0., 1., 1., 0.], &[4], &device);
//! for _ in 0..200 {
//! opt.zero_grad();
//! let loss = F::cross_entropy(&model.forward(&x), &y);
//! loss.backward();
//! opt.step();
//! }
//! ```
//!
//! The LLM fine-tuning stack (LoRA, LFM2/Llama blocks, the CLI) is built on
//! `ferrotensor-backend`, `ferrotensor-autograd` and `ferrotensor-graph`.
pub use Device;
pub use manual_seed;
pub use ;
/// Prelude module - import everything you need with `use ferrotensor::prelude::*`