diff --git a/onnxruntime/contrib_ops/cuda/transformers/generation_cuda_impl.cu b/onnxruntime/contrib_ops/cuda/transformers/generation_cuda_impl.cu index 45ed087aac..5e1f14c547 100644 --- a/onnxruntime/contrib_ops/cuda/transformers/generation_cuda_impl.cu +++ b/onnxruntime/contrib_ops/cuda/transformers/generation_cuda_impl.cu @@ -434,6 +434,10 @@ void LaunchBeamSearchScorer_Process(BeamScorerState& state_cpu, gsl::span next_tokens, gsl::span 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(), diff --git a/onnxruntime/contrib_ops/cuda/transformers/generation_cuda_impl.h b/onnxruntime/contrib_ops/cuda/transformers/generation_cuda_impl.h index 0a68a822c7..3bf8ef34b3 100644 --- a/onnxruntime/contrib_ops/cuda/transformers/generation_cuda_impl.h +++ b/onnxruntime/contrib_ops/cuda/transformers/generation_cuda_impl.h @@ -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_;