Skip to content

Commit

Permalink
Modified llama_model_quantize to accept argument by ref instead o…
Browse files Browse the repository at this point in the history
…f pointer.
  • Loading branch information
martindevans committed Apr 26, 2024
1 parent ccc49eb commit 58ec798
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
10 changes: 5 additions & 5 deletions LLama/LLamaQuantizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@ public static bool Quantize(
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;
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion LLama/Native/NativeApi.Quantize.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public static partial class NativeApi
/// <param name="param"></param>
/// <returns>Returns 0 on success</returns>
[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);
}
}

0 comments on commit 58ec798

Please sign in to comment.