Commit 5364cf9
committed
feat(LlamaContext): add safety checks and docstrings to logits retrieval
- Add explicit null pointer validation to `get_logits` and `get_logits_ith`.
These methods now raise a `RuntimeError` instead of silently returning
invalid pointers when logits are unavailable or the index is out of bounds.
- Add comprehensive docstrings to both methods, detailing the underlying
buffer shape and memory layout.
- Include a performance warning in `get_logits_ith` about the internal
synchronization/reordering overhead to discourage its use on the hot path.
Signed-off-by: JamePeng <jame_peng@sina.com>1 parent d90895d commit 5364cf9
1 file changed
Lines changed: 26 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
758 | 768 | | |
759 | | - | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
760 | 773 | | |
761 | 774 | | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
762 | 783 | | |
763 | | - | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
764 | 788 | | |
765 | 789 | | |
766 | 790 | | |
| |||
0 commit comments