Skip to content

Commit d0f7981

Browse files
Added conditional compilation code to progress_callback (in LlamaModelParams struct) so the struct plays nice with legacy NET Framework 4.8 (#593)
1 parent 884641f commit d0f7981

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

LLama/Native/LLamaModelParams.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,19 @@ public unsafe struct LLamaModelParams
2727
/// <summary>
2828
/// how to split layers across multiple GPUs (size: <see cref="NativeApi.llama_max_devices"/>)
2929
/// </summary>
30-
public float* tensor_split;
31-
30+
public float* tensor_split;
31+
3232
/// <summary>
3333
/// called with a progress value between 0 and 1, pass NULL to disable. If the provided progress_callback
3434
/// returns true, model loading continues. If it returns false, model loading is immediately aborted.
3535
/// </summary>
36+
#if NETSTANDARD2_0
37+
// this code is intended to be used when running LlamaSharp on NET Framework 4.8 (NET Standard 2.0)
38+
// as NET Framework 4.8 does not play nice with the LlamaProgressCallback type
39+
public IntPtr progress_callback;
40+
#else
3641
public LlamaProgressCallback progress_callback;
42+
#endif
3743

3844
/// <summary>
3945
/// context pointer passed to the progress callback

0 commit comments

Comments
 (0)