Class SafeTensors
java.lang.Object
ai.beestream.jitnn.io.SafeTensors
Reads and writes the safetensors format (Hugging Face): an 8-byte little-endian header length,
a JSON header that maps each tensor name to its dtype, shape and byte range, optional
__metadata__ string pairs, then the raw little-endian data. jitNN's checkpoints use it, so
they open in Python with safetensors.torch.load_file.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordOne tensor of a file: its type (null when jitNN has no such type, e.g.static final recordA file's header: the tensors, in file order, and the metadata.static final recordThe data to write for one tensor: its type, shape, and a segment of exactly its bytes. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringThe safetensors name ofdtype; GGUF block formats have none.static voidread(Path file, SafeTensors.Entry entry, MemorySegment target) Readsentry's bytes fromfileintotarget, which must be at least that long.static SafeTensors.HeaderreadHeader(Path file) Reads the header offile.static voidWritestensors, in iteration order, andmetadatatofile.
-
Method Details
-
write
public static void write(Path file, Map<String, SafeTensors.Source> tensors, Map<String, String> metadata) throws IOExceptionWritestensors, in iteration order, andmetadatatofile.- Throws:
IOException
-
readHeader
Reads the header offile.- Throws:
IOException
-
read
public static void read(Path file, SafeTensors.Entry entry, MemorySegment target) throws IOException Readsentry's bytes fromfileintotarget, which must be at least that long.- Throws:
IOException
-
name
-