Skip to content

Commit 1912211

Browse files
authored
perplexity : fix KL divergence calculations on Windows (#5273)
1 parent e437b37 commit 1912211

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

examples/perplexity/perplexity.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -457,14 +457,14 @@ static results_perplexity perplexity(llama_context * ctx, const gpt_params & par
457457

458458
std::ofstream logits_stream;
459459
if (!params.logits_file.empty()) {
460-
logits_stream.open(params.logits_file.c_str());
460+
logits_stream.open(params.logits_file.c_str(), std::ios::binary);
461461
if (!logits_stream.is_open()) {
462462
fprintf(stderr, "%s: failed to open %s for writing\n", __func__, params.logits_file.c_str());
463463
return {};
464464
}
465465
fprintf(stderr, "%s: saving all logits to %s\n", __func__, params.logits_file.c_str());
466466
logits_stream.write("_logits_", 8);
467-
logits_stream.write((const char *)&n_ctx, sizeof(n_ctx));
467+
logits_stream.write(reinterpret_cast<const char *>(&n_ctx), sizeof(n_ctx));
468468
}
469469

470470
auto tim1 = std::chrono::high_resolution_clock::now();

0 commit comments

Comments
 (0)