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

Function common_opt_dataset_init

smallthinker/common/common.cpp:1522–1537  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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);
1524 const int64_t ndata = (tokens.size() - ne_datapoint - 1) / stride;
1525 ggml_opt_dataset_t result = ggml_opt_dataset_init(
1526 GGML_TYPE_I32, GGML_TYPE_I32, ne_datapoint, ne_datapoint, ndata, /*ndata_shard =*/ 1);
1527
1528 llama_token * data = (llama_token *) ggml_opt_dataset_data(result)->data;
1529 llama_token * labels = (llama_token *) ggml_opt_dataset_labels(result)->data;
1530
1531 for (int64_t idata = 0; idata < ndata; ++idata) {
1532 memcpy(data + idata*ne_datapoint, tokens.data() + idata*stride + 0, ne_datapoint*sizeof(llama_token));
1533 memcpy(labels + idata*ne_datapoint, tokens.data() + idata*stride + 1, ne_datapoint*sizeof(llama_token));
1534 }
1535
1536 return result;
1537}

Callers 1

mainFunction · 0.85

Calls 6

ggml_opt_dataset_initFunction · 0.85
ggml_opt_dataset_dataFunction · 0.85
ggml_opt_dataset_labelsFunction · 0.85
llama_n_ctxFunction · 0.50
sizeMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected