| 856 | } |
| 857 | |
| 858 | void llama_model_loader::get_mapping_range(size_t * first, size_t * last, void ** addr, int idx, ggml_context * ctx) const { |
| 859 | GGML_ASSERT(!mappings.empty()); |
| 860 | const auto & mapping = mappings.at(idx); |
| 861 | |
| 862 | *first = mapping->size(); |
| 863 | *last = 0; |
| 864 | *addr = mapping->addr(); |
| 865 | for (ggml_tensor * tensor = ggml_get_first_tensor(ctx); tensor; tensor = ggml_get_next_tensor(ctx, tensor)) { |
| 866 | const auto * weight = get_weight(ggml_get_name(tensor)); |
| 867 | if (!weight || weight->idx != idx) { |
| 868 | continue; |
| 869 | } |
| 870 | *first = std::min(*first, weight->offs); |
| 871 | *last = std::max(*last, weight->offs + ggml_nbytes(tensor)); |
| 872 | } |
| 873 | } |
| 874 | |
| 875 | void llama_model_loader::load_data_for(struct ggml_tensor * cur) const { |
| 876 | const auto & w = require_weight(ggml_get_name(cur)); |
no test coverage detected