|
1 | 1 | using System;
|
2 |
| -using System.Diagnostics; |
3 | 2 | using System.Runtime.CompilerServices;
|
4 | 3 | using System.Runtime.InteropServices;
|
5 | 4 | using Tokenizers.NET.Collections;
|
| 5 | +#if DEBUG |
| 6 | +using System.Diagnostics; |
| 7 | +#endif |
6 | 8 |
|
7 | 9 | namespace Tokenizers.NET
|
8 | 10 | {
|
@@ -37,8 +39,8 @@ public interface ITokenizeOutput
|
37 | 39 | NativeBuffer<uint> ITokenizeOutput.TokenTypeIDs => TokenTypeIDs;
|
38 | 40 | }
|
39 | 41 |
|
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 |
42 | 44 | {
|
43 | 45 | public readonly NativeBuffer<uint> IDs;
|
44 | 46 |
|
@@ -107,7 +109,11 @@ public static NativeBuffer<uint> AccessField<T>(T item)
|
107 | 109 | return item.TokenTypeIDs;
|
108 | 110 | }
|
109 | 111 | }
|
110 |
| - |
| 112 | + } |
| 113 | + |
| 114 | + // Gather APIs |
| 115 | + public readonly unsafe partial struct TokenizeOutput |
| 116 | + { |
111 | 117 | public void GatherIDsInclusiveOfOverflowing(
|
112 | 118 | NativeBuffer<uint> idsBuffer,
|
113 | 119 | out nuint totalLength)
|
@@ -250,7 +256,11 @@ private void GatherIDsInclusiveOfOverflowingCore<FieldAccessorT>(
|
250 | 256 | return;
|
251 | 257 | }
|
252 | 258 | }
|
| 259 | + } |
253 | 260 |
|
| 261 | + // Gather and Widen APIs |
| 262 | + public readonly unsafe partial struct TokenizeOutput |
| 263 | + { |
254 | 264 | public void GatherAndWidenIDsInclusiveOfOverflowing(
|
255 | 265 | NativeBuffer<ulong> idsBuffer,
|
256 | 266 | out nuint totalLength)
|
@@ -393,7 +403,11 @@ private void GatherAndWidenIDsInclusiveOfOverflowingCore<FieldAccessorT>(
|
393 | 403 | return;
|
394 | 404 | }
|
395 | 405 | }
|
| 406 | + } |
396 | 407 |
|
| 408 | + // Dispose |
| 409 | + public readonly unsafe partial struct TokenizeOutput |
| 410 | + { |
397 | 411 | private const int NUM_HANDLES = 2;
|
398 | 412 |
|
399 | 413 | [InlineArray(NUM_HANDLES)]
|
|
0 commit comments