A parsed, fully validated safetensors file held in memory.
More...
#include <safetensors.hpp>
|
| const std::vector< std::string > & | names () const |
| | Tensor names in storage order (by data offset).
|
| |
| bool | contains (const std::string &name) const |
| |
| const SafetensorsTensorInfo & | info (const std::string &name) const |
| | The header entry for name.
|
| |
| const std::map< std::string, std::string > & | metadata () const |
| | The __metadata__ string map (empty if the file has none).
|
| |
| std::pair< const uint8_t *, size_t > | bytes (const std::string &name) const |
| | The raw little-endian bytes of name, as {pointer, size}, valid while this object lives. For dtypes that don't convert to a Tensor yet.
|
| |
| Tensor | tensor (const std::string &name, DeviceBackend *backend) const |
| | Copies tensor name into a new Tensor on backend's device.
|
| |
A parsed, fully validated safetensors file held in memory.
◆ bytes()
| std::pair< const uint8_t *, size_t > pulsatrix::SafetensorsFile::bytes |
( |
const std::string & |
name | ) |
const |
The raw little-endian bytes of name, as {pointer, size}, valid while this object lives. For dtypes that don't convert to a Tensor yet.
- Exceptions
-
| std::invalid_argument | if there is no tensor called name. |
◆ contains()
| bool pulsatrix::SafetensorsFile::contains |
( |
const std::string & |
name | ) |
const |
|
inline |
◆ info()
The header entry for name.
- Exceptions
-
| std::invalid_argument | if there is none. |
◆ metadata()
| const std::map< std::string, std::string > & pulsatrix::SafetensorsFile::metadata |
( |
| ) |
const |
|
inline |
The __metadata__ string map (empty if the file has none).
◆ names()
| const std::vector< std::string > & pulsatrix::SafetensorsFile::names |
( |
| ) |
const |
|
inline |
Tensor names in storage order (by data offset).
◆ Parse()
| static SafetensorsFile pulsatrix::SafetensorsFile::Parse |
( |
std::vector< uint8_t > |
bytes | ) |
|
|
static |
Validates a file's bytes.
- Exceptions
-
| std::invalid_argument | if they are not a valid safetensors file. |
◆ Read()
| static SafetensorsFile pulsatrix::SafetensorsFile::Read |
( |
const std::string & |
path | ) |
|
|
static |
Reads and validates a file.
- Exceptions
-
| std::runtime_error | if the file can't be opened or read. |
| std::invalid_argument | if its contents are not a valid safetensors file. |
◆ tensor()
| Tensor pulsatrix::SafetensorsFile::tensor |
( |
const std::string & |
name, |
|
|
DeviceBackend * |
backend |
|
) |
| const |
Copies tensor name into a new Tensor on backend's device.
- Exceptions
-
| std::invalid_argument | if there is no tensor called name, or its dtype isn't F32 (converting F16/BF16 is roadmap IO-6). |
The documentation for this class was generated from the following file: