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

Function LOG_BATCH_TOSTR_PRETTY

common/log.h:659–693  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

657
658template <typename C, typename B>
659inline std::string LOG_BATCH_TOSTR_PRETTY(const C & ctx, const B & batch)
660{
661 std::stringstream buf;
662 buf << "[ ";
663
664 bool first = true;
665 for (int i = 0; i < batch.n_tokens; ++i)
666 {
667 if (!first) {
668 buf << ", ";
669 } else {
670 first = false;
671 }
672
673 auto detokenized = llama_token_to_piece(ctx, batch.token[i]);
674
675 detokenized.erase(
676 std::remove_if(
677 detokenized.begin(),
678 detokenized.end(),
679 [](const unsigned char c) { return !std::isprint(c); }),
680 detokenized.end());
681
682 buf
683 << "\n" << std::to_string(i)
684 << ":token '" << detokenized << "'"
685 << ":pos " << std::to_string(batch.pos[i])
686 << ":n_seq_id " << std::to_string(batch.n_seq_id[i])
687 << ":seq_id " << std::to_string(batch.seq_id[i][0])
688 << ":logits " << std::to_string(batch.logits[i]);
689 }
690 buf << " ]";
691
692 return buf.str();
693}
694
695#ifdef LOG_DISABLE_LOGS
696

Callers

nothing calls this directly

Calls 5

llama_token_to_pieceFunction · 0.70
to_stringFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
strMethod · 0.45

Tested by

no test coverage detected