You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

LLamaModelParams.cs 1.9 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. using System;
  2. using System.Runtime.InteropServices;
  3. namespace LLama.Native
  4. {
  5. /// <summary>
  6. /// A C# representation of the llama.cpp `llama_model_params` struct
  7. /// </summary>
  8. [StructLayout(LayoutKind.Sequential)]
  9. public unsafe struct LLamaModelParams
  10. {
  11. /// <summary>
  12. /// // number of layers to store in VRAM
  13. /// </summary>
  14. public int n_gpu_layers;
  15. /// <summary>
  16. /// the GPU that is used for scratch and small tensors
  17. /// </summary>
  18. public int main_gpu;
  19. /// <summary>
  20. /// how to split layers across multiple GPUs (size: <see cref="NativeApi.llama_max_devices"/>)
  21. /// </summary>
  22. public float* tensor_split;
  23. /// <summary>
  24. /// called with a progress value between 0 and 1, pass NULL to disable
  25. /// </summary>
  26. public LlamaProgressCallback progress_callback;
  27. /// <summary>
  28. /// context pointer passed to the progress callback
  29. /// </summary>
  30. public void* progress_callback_user_data;
  31. /// <summary>
  32. /// only load the vocabulary, no weights
  33. /// </summary>
  34. public bool vocab_only
  35. {
  36. readonly get => Convert.ToBoolean(_vocab_only);
  37. set => _vocab_only = Convert.ToSByte(value);
  38. }
  39. private sbyte _vocab_only;
  40. /// <summary>
  41. /// use mmap if possible
  42. /// </summary>
  43. public bool use_mmap
  44. {
  45. readonly get => Convert.ToBoolean(_use_mmap);
  46. set => _use_mmap = Convert.ToSByte(value);
  47. }
  48. private sbyte _use_mmap;
  49. /// <summary>
  50. /// force system to keep model in RAM
  51. /// </summary>
  52. public bool use_mlock
  53. {
  54. readonly get => Convert.ToBoolean(_use_mlock);
  55. set => _use_mlock = Convert.ToSByte(value);
  56. }
  57. private sbyte _use_mlock;
  58. }
  59. }