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 2.4 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. /// how to split the model across multiple GPUs
  17. /// </summary>
  18. public GPUSplitMode split_mode;
  19. /// <summary>
  20. /// the GPU that is used for scratch and small tensors
  21. /// </summary>
  22. public int main_gpu;
  23. /// <summary>
  24. /// how to split layers across multiple GPUs (size: <see cref="NativeApi.llama_max_devices"/>)
  25. /// </summary>
  26. public float* tensor_split;
  27. /// <summary>
  28. /// called with a progress value between 0 and 1, pass NULL to disable. If the provided progress_callback
  29. /// returns true, model loading continues. If it returns false, model loading is immediately aborted.
  30. /// </summary>
  31. public LlamaProgressCallback progress_callback;
  32. /// <summary>
  33. /// context pointer passed to the progress callback
  34. /// </summary>
  35. public void* progress_callback_user_data;
  36. /// <summary>
  37. /// override key-value pairs of the model meta data
  38. /// </summary>
  39. public LLamaModelMetadataOverride* kv_overrides;
  40. /// <summary>
  41. /// only load the vocabulary, no weights
  42. /// </summary>
  43. public bool vocab_only
  44. {
  45. readonly get => Convert.ToBoolean(_vocab_only);
  46. set => _vocab_only = Convert.ToSByte(value);
  47. }
  48. private sbyte _vocab_only;
  49. /// <summary>
  50. /// use mmap if possible
  51. /// </summary>
  52. public bool use_mmap
  53. {
  54. readonly get => Convert.ToBoolean(_use_mmap);
  55. set => _use_mmap = Convert.ToSByte(value);
  56. }
  57. private sbyte _use_mmap;
  58. /// <summary>
  59. /// force system to keep model in RAM
  60. /// </summary>
  61. public bool use_mlock
  62. {
  63. readonly get => Convert.ToBoolean(_use_mlock);
  64. set => _use_mlock = Convert.ToSByte(value);
  65. }
  66. private sbyte _use_mlock;
  67. }
  68. }