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.

LLamaSeqId.cs 1.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Runtime.InteropServices;
  2. namespace LLama.Native;
  3. /// <summary>
  4. /// ID for a sequence in a batch
  5. /// </summary>
  6. [StructLayout(LayoutKind.Sequential)]
  7. public record struct LLamaSeqId
  8. {
  9. /// <summary>
  10. /// LLamaSeqId with value 0
  11. /// </summary>
  12. public static readonly LLamaSeqId Zero = new LLamaSeqId(0);
  13. /// <summary>
  14. /// The raw value
  15. /// </summary>
  16. public int Value;
  17. /// <summary>
  18. /// Create a new LLamaSeqId
  19. /// </summary>
  20. /// <param name="value"></param>
  21. private LLamaSeqId(int value)
  22. {
  23. Value = value;
  24. }
  25. /// <summary>
  26. /// Convert a LLamaSeqId into an integer (extract the raw value)
  27. /// </summary>
  28. /// <param name="pos"></param>
  29. public static explicit operator int(LLamaSeqId pos) => pos.Value;
  30. /// <summary>
  31. /// Convert an integer into a LLamaSeqId
  32. /// </summary>
  33. /// <param name="value"></param>
  34. /// <returns></returns>
  35. public static explicit operator LLamaSeqId(int value) => new(value);
  36. }