You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

LLamaNativeBatch.cs 1.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace LLama.Native;
  4. using llama_token = Int32;
  5. /// <summary>
  6. /// Input data for llama_decode
  7. /// A llama_batch object can contain input about one or many sequences
  8. /// The provided arrays (i.e. token, embd, pos, etc.) must have size of n_tokens
  9. /// </summary>
  10. [StructLayout(LayoutKind.Sequential)]
  11. public unsafe struct LLamaNativeBatch
  12. {
  13. /// <summary>
  14. /// The number of items pointed at by pos, seq_id and logits.
  15. /// </summary>
  16. public int n_tokens;
  17. /// <summary>
  18. /// Either `n_tokens` of `llama_token`, or `NULL`, depending on how this batch was created
  19. /// </summary>
  20. public readonly llama_token* token;
  21. /// <summary>
  22. /// Either `n_tokens * embd * sizeof(float)` or `NULL`, depending on how this batch was created
  23. /// </summary>
  24. public readonly float* embd;
  25. /// <summary>
  26. /// the positions of the respective token in the sequence
  27. /// </summary>
  28. public readonly LLamaPos* pos;
  29. /// <summary>
  30. /// https://github.com/ggerganov/llama.cpp/blob/master/llama.h#L139 ???
  31. /// </summary>
  32. public readonly int* n_seq_id;
  33. /// <summary>
  34. /// the sequence to which the respective token belongs
  35. /// </summary>
  36. public readonly LLamaSeqId** seq_id;
  37. /// <summary>
  38. /// if zero, the logits for the respective token will not be output
  39. /// </summary>
  40. public readonly byte* logits;
  41. // Note from llama.cpp:
  42. // > helpers for smooth API transition - can be deprecated in the future
  43. // > for future-proof code, use the above fields instead and ignore everything below
  44. private LLamaPos _all_pos_0;
  45. private LLamaPos _all_pos_1;
  46. private LLamaSeqId _all_seq_id;
  47. }