mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-07-29 20:14:01 +00:00
draft
This commit is contained in:
parent
3c3103e5df
commit
9a830b77e3
2 changed files with 35 additions and 0 deletions
|
|
@ -434,6 +434,10 @@ void LaunchBeamSearchScorer_Process(BeamScorerState& state_cpu,
|
|||
gsl::span<const int32_t> next_tokens,
|
||||
gsl::span<const int32_t> next_indices,
|
||||
cudaStream_t stream) {
|
||||
for (size_t i = 0; i < beam_hyps.length(); i++) {
|
||||
dump_beam_hypotheses(&beam_hyps[i]);
|
||||
}
|
||||
|
||||
BeamSearchScorer_Process<<<1, state_cpu.batch_size_, 0, stream>>>(state_cpu,
|
||||
state,
|
||||
sequences.data(),
|
||||
|
|
|
|||
|
|
@ -52,6 +52,37 @@ struct HypothesisScore {
|
|||
float score;
|
||||
};
|
||||
|
||||
// Function to dump the data in the struct
|
||||
__device__ void dump_hypothesis_score(const struct HypothesisScore* hs) {
|
||||
printf("HypothesisScore Dump:\n");
|
||||
printf(" hypothesis_length: %d\n", hs->hypothesis_length);
|
||||
printf(" score: %f\n", hs->score);
|
||||
|
||||
printf(" hypothesis: ");
|
||||
if (hs->hypothesis_length > 0 && hs->hypothesis != NULL) {
|
||||
for (int i = 0; i < hs->hypothesis_length; ++i) {
|
||||
printf("%d ", hs->hypothesis[i]);
|
||||
}
|
||||
} else {
|
||||
printf("(empty)");
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
__device__ void dump_beam_hypotheses(const struct BeamHypotheses* bh) {
|
||||
printf("BeamHypotheses Dump:\n");
|
||||
printf(" beams_count_: %d\n", bh->beams_count_);
|
||||
printf(" beams_used_: %d\n", bh->beams_used_);
|
||||
printf(" length_penalty_: %f\n", bh->length_penalty_);
|
||||
printf(" done_: %s\n", bh->done_ ? "true" : "false");
|
||||
|
||||
printf(" beams_:\n");
|
||||
for (int i = 0; i < bh->beams_used_; ++i) {
|
||||
printf(" Beam %d:\n", i + 1);
|
||||
dump_hypothesis_score(&bh->beams_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
struct BeamHypotheses {
|
||||
HypothesisScore* beams_; // Beam width sized array of hypotheses, sorted by highest scoring
|
||||
int beams_count_;
|
||||
|
|
|
|||
Loading…
Reference in a new issue