MCPcopy Create free account
hub / github.com/appdevforall/CodeOnTheGo / load_data_for

Method load_data_for

subprojects/llama.cpp/src/llama-model-loader.cpp:948–969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

946}
947
948void llama_model_loader::load_data_for(struct ggml_tensor * cur) const {
949 const auto & w = require_weight(ggml_get_name(cur));
950
951 if (use_mmap) {
952 const auto & mapping = mappings.at(w.idx);
953 if (cur->data == nullptr) {
954 cur->data = (uint8_t *)mapping->addr() + w.offs;
955 } else {
956 memcpy(cur->data, (uint8_t *)mapping->addr() + w.offs, ggml_nbytes(cur));
957 }
958 } else {
959 GGML_ASSERT(cur->data != nullptr);
960 GGML_ASSERT(w.idx < files.size());
961 const auto & file = files.at(w.idx);
962 file->seek(w.offs, SEEK_SET);
963 file->read_raw(cur->data, ggml_nbytes(cur));
964 }
965
966 if (check_tensors && !ggml_validate_row_data(cur->type, cur->data, ggml_nbytes(cur))) {
967 throw std::runtime_error(format("tensor '%s' has invalid data", ggml_get_name(cur)));
968 }
969}
970
971bool llama_model_loader::load_all_data(
972 struct ggml_context * ctx,

Callers 1

Calls 9

ggml_get_nameFunction · 0.85
ggml_nbytesFunction · 0.85
ggml_validate_row_dataFunction · 0.85
formatFunction · 0.85
addrMethod · 0.80
atMethod · 0.65
sizeMethod · 0.65
seekMethod · 0.45
read_rawMethod · 0.45

Tested by

no test coverage detected