struct llama_model_loader { // Holds information on a model weight struct llama_tensor_weight {
uint16_t idx; // source file index
size_t offs; // tensor data offset in the original file
ggml_tensor * tensor;
llama_tensor_weight(const llama_file * file, uint16_t idx, conststruct gguf_context * gguf_ctx, ggml_tensor * tensor) : idx(idx), tensor(tensor) { constint tensor_idx = gguf_find_tensor(gguf_ctx, ggml_get_name(tensor)); if (tensor_idx < 0) { // throw std::runtime_error(format("tensor '%s' not found in the model", ggml_get_name(tensor)));
std::abort();
}
offs = gguf_get_data_offset(gguf_ctx) + gguf_get_tensor_offset(gguf_ctx, tensor_idx); if (offs + ggml_nbytes(tensor) < offs || offs + ggml_nbytes(tensor) > file->size()) { //throw std::runtime_error(format("tensor '%s' data is not within the file bounds, model is corrupted or incomplete", ggml_get_name(tensor)));
std::abort();
}
}
llama_tensor_weight(size_t buffer_size, uint16_t idx, conststruct gguf_context * gguf_ctx, ggml_tensor * tensor) : idx(idx), tensor(tensor) { constint tensor_idx = gguf_find_tensor(gguf_ctx, ggml_get_name(tensor)); if (tensor_idx < 0) { // throw std::runtime_error(format("tensor '%s' not found in the model", ggml_get_name(tensor)));
std::abort();
}
offs = gguf_get_data_offset(gguf_ctx) + gguf_get_tensor_offset(gguf_ctx, tensor_idx); if (offs + ggml_nbytes(tensor) < offs || offs + ggml_nbytes(tensor) > buffer_size) { // throw std::runtime_error(format("tensor '%s' data is not within the buffer bounds, model is corrupted or incomplete", ggml_get_name(tensor)));
std::abort();
}
}
};
// custom comparator to sort weights more nicely by layer struct weight_name_comparer { booloperator()(const std::string & a, const std::string & b) const { int a_layer = -1; int b_layer = -1;
sscanf(a.c_str(), "blk.%d.", &a_layer);
sscanf(b.c_str(), "blk.%d.", &b_layer); if (a_layer != b_layer) { return a_layer < b_layer;
} return a < b;
}
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.