@@ -1760,8 +1760,12 @@ int llama_model_quantize(
1760
1760
1761
1761
int llama_apply_lora_from_file (struct llama_context * ctx, const char * path_lora, int n_threads) {
1762
1762
// TODO: refactor all of this after PR #801
1763
+ fprintf (stderr, " %s: applying lora adapter from '%s' - please wait ...\n " , __func__, path_lora);
1764
+
1763
1765
auto & model = ctx->model ;
1764
1766
1767
+ const int64_t t_start_lora_us = ggml_time_us ();
1768
+
1765
1769
auto fin = std::ifstream (path_lora, std::ios::binary);
1766
1770
if (!fin) {
1767
1771
fprintf (stderr, " %s: failed to open '%s'\n " , __func__, path_lora);
@@ -1874,7 +1878,7 @@ int llama_apply_lora_from_file(struct llama_context * ctx, const char * path_lor
1874
1878
lora_tensors.find (base_name + " .loraB" ) != lora_tensors.end ()) {
1875
1879
1876
1880
ggml_tensor * tensor = model.tensors [base_name];
1877
- ggml_tensor * loraA = ggml_transpose (lora_ctx, lora_tensors[base_name + " .loraA" ]) ;
1881
+ ggml_tensor * loraA = lora_tensors[base_name + " .loraA" ];
1878
1882
ggml_tensor * loraB = lora_tensors[base_name + " .loraB" ];
1879
1883
1880
1884
if (tensor->ne [0 ] != loraA->ne [1 ]) {
@@ -1901,7 +1905,11 @@ int llama_apply_lora_from_file(struct llama_context * ctx, const char * path_lor
1901
1905
fprintf (stderr, " ." );
1902
1906
}
1903
1907
}
1904
- fprintf (stderr, " done\n " );
1908
+
1909
+ ggml_free (lora_ctx);
1910
+
1911
+ const int64_t t_lora_us = ggml_time_us () - t_start_lora_us;
1912
+ fprintf (stderr, " done (%.2f ms)\n " , t_lora_us / 1000.0 );
1905
1913
1906
1914
return 0 ;
1907
1915
}
0 commit comments