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.6 kB

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