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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
//! ferrotorch — PyTorch-shaped deep learning framework in Rust.
//!
//! This crate is the umbrella re-export crate. Sub-crates own the actual
//! implementation; this crate exists so users can `use ferrotorch::*;` (or
//! `use ferrotorch::prelude::*;`) and pick up the canonical public surface
//! in one import.
//!
//! # Examples
//!
//! ```rust,no_run
//! use ferrotorch::{FerrotorchResult, zeros};
//!
//! fn main() -> FerrotorchResult<()> {
//! let t = zeros::<f32>(&[2, 3])?;
//! assert_eq!(t.shape(), &[2, 3]);
//! Ok(())
//! }
//! ```
//!
//! See the `prelude` module for the items most users want, and the per-feature
//! modules (`nn`, `optim`, `data`, `vision`, `train`, `serialize`, `jit`,
//! `jit_script`, `distributions`, `profiler`, `hub`, `tokenize`, `gpu`,
//! `cubecl`, `mps`, `xpu`, `distributed`, `llama`, `ml`) for sub-crate access.
//!
//! Lint baseline mirrors the per-crate convention used across the workspace
//! (`ferrotorch-core`, `ferrotorch-jit`, `ferrotorch-cubecl`, etc.). Workspace
//! `[lints]` is intentionally not used — every crate carries its own
//! `#![warn/deny(...)]` so the policy lives next to the code it governs.
//!
//! ## REQ status (per `.design/ferrotorch/lib.md`)
//!
//! | REQ | Status | Evidence |
//! |---|---|---|
//! | REQ-1 | SHIPPED | impl: crate `//!` doc-comment at top of `ferrotorch/src/lib.rs` mirrors `torch/__init__.py:1-9` module docstring; consumer: rustdoc `no_run` example block in the same docstring (run by `cargo test -p ferrotorch --doc`). |
//! | REQ-2 | SHIPPED | impl: `pub use ferrotorch_core::*;` at `ferrotorch/src/lib.rs` mirrors `torch/__init__.py:68-141` flat `__all__`; consumer: doctest at the top of this file imports `ferrotorch::{FerrotorchResult, zeros}` directly. |
//! | REQ-3 | SHIPPED | impl: `pub mod prelude { ... }` in `ferrotorch/src/lib.rs` mirrors `from torch import nn, optim` convention; consumer: the `//!` doc-comment promises `use ferrotorch::prelude::*;` as the canonical one-import entry point — published-crate API contract. |
//! | REQ-4 | SHIPPED | impl: always-on `pub mod nn` / `pub mod optim` / `pub mod data` / `pub mod vision` in `ferrotorch/src/lib.rs` mirror `torch.nn` / `torch.optim` / `torch.utils.data` / `torchvision`; consumer: `ferrotorch/tests/public_surface.rs:22-25` compile-time pins each path (test harness for the public-API contract is the contract auditor); downstream-of-workspace: `crates.io/ferrotorch` users. |
//! | REQ-5 | SHIPPED | impl: 11 `#[cfg(feature = "<flag>")] pub mod <name>` blocks in `ferrotorch/src/lib.rs` mirror upstream optional namespaces; consumer: `ferrotorch/Cargo.toml:15-43` enumerates each matching feature flag; the published-crate contract is the boundary consumer per goal.md S5. |
//! | REQ-6 | SHIPPED | impl: `#[cfg(not(target_env = "msvc"))] #[global_allocator] static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;` in `ferrotorch/src/lib.rs`; consumer: every binary linking the `ferrotorch` crate (e.g. `cargo run --example train_mnist -p ferrotorch` via `ferrotorch/examples/train_mnist.rs`) picks up the allocator via the rustc `#[global_allocator]` mechanism. |
//! | REQ-7 | SHIPPED | impl: lint baseline block `#![warn(clippy::all, clippy::pedantic)] #![deny(rust_2018_idioms, missing_debug_implementations)] #![allow(missing_docs)]` in `ferrotorch/src/lib.rs`; consumer: `cargo clippy -p ferrotorch --lib -- -D warnings` gates every commit per goal.md Step 7. |
//! | REQ-8 | SHIPPED | impl: `llama-cuda = ["llama", "gpu", "ferrotorch-llama/cuda"]` at `ferrotorch/Cargo.toml:42`; consumer: the `//!` doc-comment in this file references `llama-cuda` as a documented feature combination; published-crate users are the boundary consumer. |
//!
//! Closes #1346.
// `missing_docs` is held off here because the umbrella crate is exclusively
// re-exports from already-documented sub-crates; a workspace-wide rustdoc
// pass is tracked separately and will lift this allow once it lands.
static GLOBAL: MiMalloc = MiMalloc;
pub use *;
/// Prelude module — import everything commonly needed.
/// Neural network modules and layers.
/// Optimizers and learning rate schedulers.
/// Data loading, datasets, samplers, and transforms.
/// Computer vision models, datasets, and transforms.
/// Training loop, Learner, callbacks, and metrics.
/// Model serialization: ONNX export, `PyTorch` import, safetensors, GGUF.
/// JIT tracing, IR graph, optimization passes, and code generation.
/// `#[script]` proc macro for source-based graph capture.
/// Probability distributions for sampling and variational inference.
/// Performance profiling and Chrome trace export.
/// Model hub for downloading and caching pretrained models.
/// `HuggingFace` tokenizer wrapper (BPE, `WordPiece`, Unigram).
/// CUDA GPU backend with PTX kernels and cuBLAS.
/// Portable GPU compute via `CubeCL` (CUDA + WGPU + `ROCm`).
/// Apple Silicon Metal Performance Shaders backend.
/// Intel Arc / Data Center GPU Max via `CubeCL` wgpu.
/// Distributed training: DDP, collective ops, TCP backend.
/// Llama 3 model composition and (with `llama-cuda`) GPU bf16 inference.
/// Sklearn-compatible adapter and classic-ML datasets.