MCPcopy Create free account
hub / github.com/Tiiny-AI/PowerInfer / common_control_vector_load

Function common_control_vector_load

smallthinker/common/common.cpp:1488–1520  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1486}
1487
1488common_control_vector_data common_control_vector_load(const std::vector<common_control_vector_load_info> & load_infos) {
1489 common_control_vector_data result = { -1, {} };
1490
1491 for (const auto & info : load_infos) {
1492 auto cur = common_control_vector_load_one(info);
1493
1494 if (cur.n_embd == -1) {
1495 result.n_embd = -1;
1496 break;
1497 }
1498 if (result.n_embd != -1 && result.n_embd != cur.n_embd) {
1499 LOG_ERR("%s: control vectors in %s does not match previous dimensions\n", __func__, info.fname.c_str());
1500 result.n_embd = -1;
1501 break;
1502 }
1503
1504 if (result.n_embd == -1) {
1505 result = std::move(cur);
1506 } else {
1507 result.data.resize(std::max(result.data.size(), cur.data.size()), 0.0f); // extend if necessary
1508 for (size_t i = 0; i < cur.data.size(); i++) {
1509 result.data[i] += cur.data[i];
1510 }
1511 }
1512 }
1513
1514 if (result.n_embd == -1) {
1515 LOG_ERR("%s: no valid control vector files passed\n", __func__);
1516 result.data.clear();
1517 }
1518
1519 return result;
1520}
1521
1522ggml_opt_dataset_t common_opt_dataset_init(struct llama_context * ctx, const std::vector<llama_token> & tokens, int64_t stride) {
1523 const int64_t ne_datapoint = llama_n_ctx(ctx);

Callers 1

common_init_from_paramsFunction · 0.85

Calls 6

maxFunction · 0.85
c_strMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected