Skip to content

Commit 09c91ea

Browse files
committed
Split TokenizeOutput.cs into partials
1 parent 15da6e2 commit 09c91ea

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

Tokenizers.NET/TokenizeOutput.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
using System;
2-
using System.Diagnostics;
32
using System.Runtime.CompilerServices;
43
using System.Runtime.InteropServices;
54
using Tokenizers.NET.Collections;
5+
#if DEBUG
6+
using System.Diagnostics;
7+
#endif
68

79
namespace Tokenizers.NET
810
{
@@ -37,8 +39,8 @@ public interface ITokenizeOutput
3739
NativeBuffer<uint> ITokenizeOutput.TokenTypeIDs => TokenTypeIDs;
3840
}
3941

40-
[StructLayout(LayoutKind.Sequential)]
41-
public readonly unsafe struct TokenizeOutput: ITokenizeOutput, IDisposable
42+
[StructLayout(LayoutKind.Sequential)] // Data structures
43+
public readonly unsafe partial struct TokenizeOutput: ITokenizeOutput, IDisposable
4244
{
4345
public readonly NativeBuffer<uint> IDs;
4446

@@ -107,7 +109,11 @@ public static NativeBuffer<uint> AccessField<T>(T item)
107109
return item.TokenTypeIDs;
108110
}
109111
}
110-
112+
}
113+
114+
// Gather APIs
115+
public readonly unsafe partial struct TokenizeOutput
116+
{
111117
public void GatherIDsInclusiveOfOverflowing(
112118
NativeBuffer<uint> idsBuffer,
113119
out nuint totalLength)
@@ -250,7 +256,11 @@ private void GatherIDsInclusiveOfOverflowingCore<FieldAccessorT>(
250256
return;
251257
}
252258
}
259+
}
253260

261+
// Gather and Widen APIs
262+
public readonly unsafe partial struct TokenizeOutput
263+
{
254264
public void GatherAndWidenIDsInclusiveOfOverflowing(
255265
NativeBuffer<ulong> idsBuffer,
256266
out nuint totalLength)
@@ -393,7 +403,11 @@ private void GatherAndWidenIDsInclusiveOfOverflowingCore<FieldAccessorT>(
393403
return;
394404
}
395405
}
406+
}
396407

408+
// Dispose
409+
public readonly unsafe partial struct TokenizeOutput
410+
{
397411
private const int NUM_HANDLES = 2;
398412

399413
[InlineArray(NUM_HANDLES)]

0 commit comments

Comments
 (0)