01-load-progress.diff 1.5 KB

12345678910111213141516171819202122232425262728293031
  1. diff --git a/common/common.cpp b/common/common.cpp
  2. index 2c05a4d4..927f0e3d 100644
  3. --- a/common/common.cpp
  4. +++ b/common/common.cpp
  5. @@ -2093,6 +2093,8 @@ struct llama_model_params llama_model_params_from_gpt_params(const gpt_params &
  6. mparams.use_mmap = params.use_mmap;
  7. mparams.use_mlock = params.use_mlock;
  8. mparams.check_tensors = params.check_tensors;
  9. + mparams.progress_callback = params.progress_callback;
  10. + mparams.progress_callback_user_data = params.progress_callback_user_data;
  11. if (params.kv_overrides.empty()) {
  12. mparams.kv_overrides = NULL;
  13. } else {
  14. diff --git a/common/common.h b/common/common.h
  15. index 65c0ef81..ebca2c77 100644
  16. --- a/common/common.h
  17. +++ b/common/common.h
  18. @@ -184,6 +184,13 @@ struct gpt_params {
  19. std::string mmproj = ""; // path to multimodal projector
  20. std::vector<std::string> image; // path to image file(s)
  21. + // Called with a progress value between 0.0 and 1.0. Pass NULL to disable.
  22. + // If the provided progress_callback returns true, model loading continues.
  23. + // If it returns false, model loading is immediately aborted.
  24. + llama_progress_callback progress_callback = NULL;
  25. + // context pointer passed to the progress callback
  26. + void * progress_callback_user_data;
  27. +
  28. // embedding
  29. bool embedding = false; // get only sentence embedding
  30. int32_t embd_normalize = 2; // normalisation for embendings (-1=none, 0=max absolute int16, 1=taxicab, 2=euclidean, >2=p-norm)