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
//! Clearly documented headers for all BPAT versions.
/// The original BPAT header. Used `f64` storage.
///
/// Used on `briny_ai` `v0.1.0`-`v0.2.2`.
///
/// # Format
///
/// This version looks like this:
///
/// ```text
/// ┌──────────────┬────────────────────────────┐
/// │ Header │ Tensors │
/// ├──────────────┼────────────────────────────┤
/// │ `bpat` │ u64: ndim │
/// │ u8: count │ [u64; ndim] shape │
/// │ │ [f64; prod(shape)] data │
/// └──────────────┴────────────────────────────┘
/// ```
pub const BPAT_MAGIC_V0: = *b"bpat";
/// The first BPAT header with checksums.
///
/// Created on `briny_ai` `v0.3.0`.
///
/// # Format
///
/// This version looks like this:
///
/// ```text
/// ┌──────────────┬────────────────────────────┬────────────────────┐
/// │ Header │ Tensors │ Checksum │
/// ├──────────────┼────────────────────────────┼────────────────────┤
/// │ `BPATv1\0\0` │ u64: ndim │ u32: file checksum │
/// │ u8: count │ [u64; ndim] shape │ │
/// │ │ [f64; prod(shape)] data │ │
/// │ │ u32: checksum │ │
/// └──────────────┴────────────────────────────┴────────────────────┘
/// ```
pub const BPAT_MAGIC_V1: = *b"BPATv1\0\0";
/// A more compact BPAT format with checksums. Started using `f32` storage.
///
/// Created on `briny_ai` `v0.6.0`.
///
/// # Format
///
/// This version looks like this:
///
/// ```text
/// ┌──────────────┬────────────────────────────┬────────────────────┐
/// │ Header │ Tensors │ Checksum │
/// ├──────────────┼────────────────────────────┼────────────────────┤
/// │ `BPATv1m\0` │ u32: ndim │ u32: file checksum │
/// │ u8: count │ [u32; ndim] shape │ │
/// │ │ [f32; prod(shape)] data │ │
/// │ │ u32: checksum │ │
/// └──────────────┴────────────────────────────┴────────────────────┘
/// ```
pub const BPAT_MAGIC_V1_MICRO: = *b"BPATv1m\0";
/// The most compact BPAT header. Started using `f16` storage.
///
/// Created on `fused_gpu` `v0.1.0-alpha.4`.
///
/// # Format
///
/// This version looks like this:
///
/// ```text
/// ┌──────────────┬────────────────────────────┐
/// │ Header │ Tensors │
/// ├──────────────┼────────────────────────────┤
/// │ `BPAT\0f16` │ u32: ndim │
/// │ u8: count │ [u32; ndim] shape │
/// │ │ [f16; prod(shape)] data │
/// └──────────────┴────────────────────────────┘
/// ```
pub const BPAT_MAGIC_V2_F16: = *b"BPAT\0f16";
/// Same as [`BPAT_MAGIC_V2_F16`], but uses `bf16` storage instead.
///
/// Created on `fused_gpu` `v0.1.0-alpha.4`.
///
/// # Format
///
/// This version looks like this:
///
/// ```text
/// ┌──────────────┬────────────────────────────┐
/// │ Header │ Tensors │
/// ├──────────────┼────────────────────────────┤
/// │ `BPATbf16` │ u32: ndim │
/// │ u8: count │ [u32; ndim] shape │
/// │ │ [bf16; prod(shape)] data │
/// └──────────────┴────────────────────────────┘
/// ```
pub const BPAT_MAGIC_V2_BF16: = *b"BPATbf16";
/// Same as [`BPAT_MAGIC_V2_F16`], but uses `f32` storage instead.
///
/// Created on `fused_gpu` `v0.1.0-alpha.4`.
///
/// # Format
///
/// This version looks like this:
///
/// ```text
/// ┌──────────────┬────────────────────────────┐
/// │ Header │ Tensors │
/// ├──────────────┼────────────────────────────┤
/// │ `BPAT\0f32` │ u32: ndim │
/// │ u8: count │ [u32; ndim] shape │
/// │ │ [f32; prod(shape)] data │
/// └──────────────┴────────────────────────────┘
/// ```
pub const BPAT_MAGIC_V2_F32: = *b"BPAT\0f32";