A Hugging Face checkpoint directory's weights: model.safetensors, or the shards listed by model.safetensors.index.json (IO-5). Shards are memory-mapped, so opening a checkpoint reads only headers, and a tensor's bytes are paged in when it is read.
More...
#include <hf_model.hpp>
|
| const std::vector< std::string > & | names () const |
| | Every tensor name, sorted.
|
| |
| bool | contains (const std::string &name) const |
| |
| const std::string & | shard_of (const std::string &name) const |
| | The shard file holding name.
|
| |
| const SafetensorsTensorInfo & | info (const std::string &name) const |
| | name's header entry (dtype, shape).
|
| |
| Tensor | tensor (const std::string &name, DeviceBackend *backend) const |
| | Reads name into a Tensor; see SafetensorsFile::tensor for the dtypes it converts.
|
| |
| std::vector< std::string > | shards () const |
| | The shard files, in the order first listed.
|
| |
|
| static HfCheckpoint | Open (const std::string &directory) |
| | Opens directory: the index if there is one, otherwise the single file.
|
| |
A Hugging Face checkpoint directory's weights: model.safetensors, or the shards listed by model.safetensors.index.json (IO-5). Shards are memory-mapped, so opening a checkpoint reads only headers, and a tensor's bytes are paged in when it is read.
◆ contains()
| bool pulsatrix::HfCheckpoint::contains |
( |
const std::string & |
name | ) |
const |
|
inline |
◆ info()
name's header entry (dtype, shape).
- Exceptions
-
| std::invalid_argument | if there's none. |
◆ names()
| const std::vector< std::string > & pulsatrix::HfCheckpoint::names |
( |
| ) |
const |
|
inline |
Every tensor name, sorted.
◆ Open()
| static HfCheckpoint pulsatrix::HfCheckpoint::Open |
( |
const std::string & |
directory | ) |
|
|
static |
Opens directory: the index if there is one, otherwise the single file.
- Exceptions
-
| std::runtime_error | if neither file exists, or a file can't be read. |
| std::invalid_argument | if the index is malformed, names a shard outside the directory (any path separator or ..), lists a tensor its shard doesn't hold, or a shard holds a tensor the index doesn't list; or a shard isn't valid safetensors. |
◆ shard_of()
| const std::string & pulsatrix::HfCheckpoint::shard_of |
( |
const std::string & |
name | ) |
const |
The shard file holding name.
- Exceptions
-
| std::invalid_argument | if there's no such tensor. |
◆ shards()
| std::vector< std::string > pulsatrix::HfCheckpoint::shards |
( |
| ) |
const |
The shard files, in the order first listed.
◆ tensor()
| Tensor pulsatrix::HfCheckpoint::tensor |
( |
const std::string & |
name, |
|
|
DeviceBackend * |
backend |
|
) |
| const |
The documentation for this class was generated from the following file: