@@ -605,6 +605,11 @@ std::pair<std::unordered_map<std::string, float>, std::string> extract_and_remov
605
605
return std::make_pair (filename2multiplier, text);
606
606
}
607
607
608
+ void ggml_backend_tensor_get_and_sync (ggml_backend_t backend, const struct ggml_tensor * tensor, void * data, size_t offset, size_t size) {
609
+ ggml_backend_tensor_get (tensor, data, offset, size);
610
+ ggml_backend_synchronize (backend);
611
+ }
612
+
608
613
/* ================================================== CLIPTokenizer ===================================================*/
609
614
610
615
const std::string UNK_TOKEN = " <|endoftext|>" ;
@@ -1410,7 +1415,7 @@ struct CLIPTextModel {
1410
1415
#ifdef GGML_PERF
1411
1416
ggml_graph_print (gf);
1412
1417
#endif
1413
- ggml_backend_tensor_get ( gf->nodes [gf->n_nodes - 1 ], work_output->data , 0 , ggml_nbytes (work_output));
1418
+ ggml_backend_tensor_get_and_sync (backend, gf->nodes [gf->n_nodes - 1 ], work_output->data , 0 , ggml_nbytes (work_output));
1414
1419
return work_output;
1415
1420
}
1416
1421
@@ -2688,7 +2693,7 @@ struct UNetModel {
2688
2693
ggml_graph_print (gf);
2689
2694
#endif
2690
2695
2691
- ggml_backend_tensor_get ( gf->nodes [gf->n_nodes - 1 ], work_latent->data , 0 , ggml_nbytes (work_latent));
2696
+ ggml_backend_tensor_get_and_sync (backend, gf->nodes [gf->n_nodes - 1 ], work_latent->data , 0 , ggml_nbytes (work_latent));
2692
2697
}
2693
2698
2694
2699
void end () {
@@ -3499,7 +3504,7 @@ struct AutoEncoderKL {
3499
3504
ggml_graph_print (gf);
3500
3505
#endif
3501
3506
3502
- ggml_backend_tensor_get ( gf->nodes [gf->n_nodes - 1 ], work_result->data , 0 , ggml_nbytes (work_result));
3507
+ ggml_backend_tensor_get_and_sync (backend, gf->nodes [gf->n_nodes - 1 ], work_result->data , 0 , ggml_nbytes (work_result));
3503
3508
}
3504
3509
3505
3510
void end () {
@@ -4182,7 +4187,7 @@ struct TinyAutoEncoder {
4182
4187
ggml_graph_print (gf);
4183
4188
#endif
4184
4189
4185
- ggml_backend_tensor_get ( gf->nodes [gf->n_nodes - 1 ], work_result->data , 0 , ggml_nbytes (work_result));
4190
+ ggml_backend_tensor_get_and_sync (backend, gf->nodes [gf->n_nodes - 1 ], work_result->data , 0 , ggml_nbytes (work_result));
4186
4191
}
4187
4192
4188
4193
void end () {
@@ -4705,7 +4710,7 @@ struct ESRGAN {
4705
4710
ggml_graph_print (gf);
4706
4711
#endif
4707
4712
ggml_tensor* out = gf->nodes [gf->n_nodes - 1 ];
4708
- ggml_backend_tensor_get ( out, work_result->data , 0 , ggml_nbytes (out));
4713
+ ggml_backend_tensor_get_and_sync (backend, out, work_result->data , 0 , ggml_nbytes (out));
4709
4714
}
4710
4715
4711
4716
void end () {
0 commit comments