|
18 | 18 | #include <cstring>
|
19 | 19 | #include <ctime>
|
20 | 20 | #include <stdexcept>
|
| 21 | +#include <streambuf> |
21 | 22 |
|
22 | 23 | #if defined(_MSC_VER)
|
23 | 24 | #pragma warning(disable: 4244 4267) // possible loss of data
|
@@ -298,6 +299,28 @@ struct llama_model * llama_model_load_from_splits(const char ** paths, size_t n_
|
298 | 299 | return llama_model_load_from_file_impl(ml, params);
|
299 | 300 | }
|
300 | 301 |
|
| 302 | +struct llama_model * llama_model_load_from_split_futures(const char ** paths, size_t n_paths, const char * context, |
| 303 | + const char * tensor_list_file, |
| 304 | + struct llama_model_params params) { |
| 305 | + std::vector<std::string> splits = splits_from_c_paths(paths, n_paths); |
| 306 | + if (splits.empty()) { |
| 307 | + return nullptr; |
| 308 | + } |
| 309 | + std::string tensor_list_file_str(tensor_list_file); |
| 310 | + |
| 311 | + load_input_variant::buffer_future_load_input loader_input{ splits.front(), context, splits, tensor_list_file_str }; |
| 312 | + override_and_disable_mmap(params); |
| 313 | + llama_model_loader ml(loader_input, params.use_mmap, params.check_tensors, params.kv_overrides, |
| 314 | + params.tensor_buft_overrides); |
| 315 | + return llama_model_load_from_file_impl(ml, params); |
| 316 | +} |
| 317 | + |
| 318 | +bool llama_model_load_fulfill_split_future(const char * path, const char * context, |
| 319 | + std::unique_ptr<std::basic_streambuf<uint8_t>> && streambuf) { |
| 320 | + return llama_future_file_buffer_ro::fulfill_promise(path, context, |
| 321 | + std::make_unique<llama_file_buffer_ro>(std::move(streambuf))); |
| 322 | +} |
| 323 | + |
301 | 324 | void llama_model_save_to_file(const struct llama_model * model, const char * path_model) {
|
302 | 325 | llama_model_saver ms(*model);
|
303 | 326 | ms.add_kv_from_model();
|
|
0 commit comments