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.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. /// override key-value pairs of the model meta data
  33. /// </summary>
  34. public LLamaModelMetadataOverride* kv_overrides;
  35. /// <summary>
  36. /// only load the vocabulary, no weights
  37. /// </summary>
  38. public bool vocab_only
  39. {
  40. readonly get => Convert.ToBoolean(_vocab_only);
  41. set => _vocab_only = Convert.ToSByte(value);
  42. }
  43. private sbyte _vocab_only;
  44. /// <summary>
  45. /// use mmap if possible
  46. /// </summary>
  47. public bool use_mmap
  48. {
  49. readonly get => Convert.ToBoolean(_use_mmap);
  50. set => _use_mmap = Convert.ToSByte(value);
  51. }
  52. private sbyte _use_mmap;
  53. /// <summary>
  54. /// force system to keep model in RAM
  55. /// </summary>
  56. public bool use_mlock
  57. {
  58. readonly get => Convert.ToBoolean(_use_mlock);
  59. set => _use_mlock = Convert.ToSByte(value);
  60. }
  61. private sbyte _use_mlock;
  62. }
  63. }