Skip to content

Commit a2f8573

Browse files
authored
Merge pull request #698 from martindevans/slightly_safer_quantize_params
Slightly Safer Quantize Params
2 parents ecb359c + 58ec798 commit a2f8573

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

LLama/LLamaQuantizer.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ public static bool Quantize(
3434
quantizeParams.nthread = nthread;
3535
quantizeParams.allow_requantize = allowRequantize;
3636
quantizeParams.quantize_output_tensor = quantizeOutputTensor;
37-
//todo: fill in other quantize params fields.
3837

39-
unsafe
40-
{
41-
return NativeApi.llama_model_quantize(srcFileName, dstFilename, &quantizeParams) == 0;
42-
}
38+
// todo: fill in other quantize params fields.
39+
// This method could probably do with a redesign - passing in a config object (maybe directly
40+
// expose `LLamaModelQuantizeParams`) instead of an ever growing list of method parameters!
41+
42+
return NativeApi.llama_model_quantize(srcFileName, dstFilename, ref quantizeParams) == 0;
4343
}
4444

4545
/// <summary>

LLama/Native/NativeApi.Quantize.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public static partial class NativeApi
1212
/// <param name="param"></param>
1313
/// <returns>Returns 0 on success</returns>
1414
[DllImport(libraryName, CallingConvention = CallingConvention.Cdecl)]
15-
public static extern unsafe uint llama_model_quantize(string fname_inp, string fname_out, LLamaModelQuantizeParams* param);
15+
public static extern uint llama_model_quantize(string fname_inp, string fname_out, ref LLamaModelQuantizeParams param);
1616
}
1717
}

0 commit comments

Comments
 (0)