-
Notifications
You must be signed in to change notification settings - Fork 381
/
Copy pathLLamaSeqId.cs
46 lines (40 loc) · 1.08 KB
/
LLamaSeqId.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
namespace LLama.Native;
/// <summary>
/// ID for a sequence in a batch
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public record struct LLamaSeqId
{
/// <summary>
/// LLamaSeqId with value 0
/// </summary>
public static readonly LLamaSeqId Zero = new LLamaSeqId(0);
/// <summary>
/// The raw value
/// </summary>
public int Value;
/// <summary>
/// Create a new LLamaSeqId
/// </summary>
/// <param name="value"></param>
private LLamaSeqId(int value)
{
Value = value;
}
/// <summary>
/// Convert a LLamaSeqId into an integer (extract the raw value)
/// </summary>
/// <param name="pos"></param>
public static explicit operator int(LLamaSeqId pos) => pos.Value;
/// <summary>
/// Convert an integer into a LLamaSeqId
/// </summary>
/// <param name="value"></param>
/// <returns></returns>
public static explicit operator LLamaSeqId(int value) => new(value);
/// <inheritdoc />
public readonly override string ToString()
{
return Value.ToString();
}
}