From 58ec798bff24cb44921fb26376c7c8f1983fdc2b Mon Sep 17 00:00:00 2001 From: Martin Evans Date: Fri, 26 Apr 2024 01:35:13 +0100 Subject: [PATCH] Modified `llama_model_quantize` to accept argument by `ref` instead of pointer. --- LLama/LLamaQuantizer.cs | 10 +++++----- LLama/Native/NativeApi.Quantize.cs | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/LLama/LLamaQuantizer.cs b/LLama/LLamaQuantizer.cs index 4e541e92..a1415887 100644 --- a/LLama/LLamaQuantizer.cs +++ b/LLama/LLamaQuantizer.cs @@ -34,12 +34,12 @@ namespace LLama quantizeParams.nthread = nthread; quantizeParams.allow_requantize = allowRequantize; quantizeParams.quantize_output_tensor = quantizeOutputTensor; - //todo: fill in other quantize params fields. - unsafe - { - return NativeApi.llama_model_quantize(srcFileName, dstFilename, &quantizeParams) == 0; - } + // todo: fill in other quantize params fields. + // This method could probably do with a redesign - passing in a config object (maybe directly + // expose `LLamaModelQuantizeParams`) instead of an ever growing list of method parameters! + + return NativeApi.llama_model_quantize(srcFileName, dstFilename, ref quantizeParams) == 0; } /// diff --git a/LLama/Native/NativeApi.Quantize.cs b/LLama/Native/NativeApi.Quantize.cs index 1c4909bf..a2a372bc 100644 --- a/LLama/Native/NativeApi.Quantize.cs +++ b/LLama/Native/NativeApi.Quantize.cs @@ -12,6 +12,6 @@ namespace LLama.Native /// /// Returns 0 on success [DllImport(libraryName, CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe uint llama_model_quantize(string fname_inp, string fname_out, LLamaModelQuantizeParams* param); + public static extern uint llama_model_quantize(string fname_inp, string fname_out, ref LLamaModelQuantizeParams param); } }