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
// SPDX-License-Identifier: MIT OR Apache-2.0
//! Safetensors support — transport convenience over the upstream
//! parser.
//!
//! Unlike the other modules in `fuel-formats`, the byte-level
//! safetensors parser is **not implemented here**. The upstream
//! [`safetensors`] crate already provides a complete, transport-
//! independent parser ([`SafeTensors::deserialize`] over `&[u8]`,
//! [`TensorView`], [`Dtype`], [`View`]). Re-implementing it would be
//! wasted effort.
//!
//! What this module *does* provide:
//!
//! - **Re-exports** of the parser surface so transport-only consumers
//! can depend on `fuel-formats` instead of pulling in upstream
//! `safetensors` directly.
//! - [`MmapedFile`] — a low-level memory-mapped file handle that
//! produces a [`SafeTensors`] view via [`MmapedFile::deserialize`].
//! Transport-independent in the same sense as the rest of
//! `fuel-formats`: it owns the bytes, and the parser surface
//! above sits on top.
//!
//! The mmap/view wrappers `fuel_loaders::safetensors::MmapedSafetensors`
//! and `fuel_loaders::safetensors::BufferedSafetensors` sit downstream in
//! `fuel-loaders`. They hand out `TensorView`s and nothing more — the
//! caller decodes the bytes.
//!
//! B6 deleted the eager tensor-construction half that used to live
//! alongside them (`load`, `load_buffer`, `save`, `SliceSafetensors`,
//! and the `Load` trait's `.load(device)`), because each called
//! `Tensor::from_*` or `Storage::*` on the retired eager `Tensor`.
//! Nothing replaced them: the lazy loaders read `view.data()` directly.
use ;
use ;
pub use SafeTensors;
pub use ;
/// A low-level memory-mapped file handle for a safetensors file.
///
/// This does not eagerly deserialize the header. Call
/// [`MmapedFile::deserialize`] to obtain a [`SafeTensors`] view that
/// can be iterated or queried for individual tensors.
///
/// # Safety
///
/// Construction is `unsafe` because it relies on memory-mapped I/O.
/// The underlying file must not be modified while this handle is
/// alive.