@@ -3155,6 +3155,8 @@ class StableDiffusionGGML {
3155
3155
struct ggml_tensor * c = ggml_new_tensor_4d (res_ctx, GGML_TYPE_F32, 1024 , 2 , 1 , 1 );
3156
3156
ggml_set_f32 (c, 0.5 );
3157
3157
3158
+ struct ggml_cplan cplan;
3159
+
3158
3160
size_t ctx_size = 10 * 1024 * 1024 ; // 10MB
3159
3161
// calculate the amount of memory required
3160
3162
{
@@ -3179,7 +3181,7 @@ class StableDiffusionGGML {
3179
3181
ctx_size += ggml_used_mem (ctx) + ggml_used_mem_of_data (ctx);
3180
3182
3181
3183
struct ggml_cgraph * diffusion_graph = ggml_build_forward_ctx (ctx, out);
3182
- struct ggml_cplan cplan = ggml_graph_plan (diffusion_graph, n_threads);
3184
+ cplan = ggml_graph_plan (diffusion_graph, n_threads);
3183
3185
3184
3186
ctx_size += cplan.work_size ;
3185
3187
LOG_DEBUG (" diffusion context need %.2fMB static memory, with work_size needing %.2fMB" ,
@@ -3212,7 +3214,7 @@ class StableDiffusionGGML {
3212
3214
ggml_hold_dynamic_tensor (out);
3213
3215
3214
3216
struct ggml_cgraph * diffusion_graph = ggml_build_forward_ctx (ctx, out);
3215
- struct ggml_cplan cplan = ggml_graph_plan (diffusion_graph, n_threads);
3217
+ cplan = ggml_graph_plan (diffusion_graph, n_threads);
3216
3218
3217
3219
ggml_set_dynamic (ctx, false );
3218
3220
struct ggml_tensor * buf = ggml_new_tensor_1d (ctx, GGML_TYPE_I8, cplan.work_size );
@@ -3257,6 +3259,7 @@ class StableDiffusionGGML {
3257
3259
true );
3258
3260
std::vector<int >& tokens = tokens_and_weights.first ;
3259
3261
std::vector<float >& weights = tokens_and_weights.second ;
3262
+ struct ggml_cplan cplan;
3260
3263
size_t ctx_size = 10 * 1024 * 1024 ; // 10MB
3261
3264
// calculate the amount of memory required
3262
3265
{
@@ -3278,8 +3281,8 @@ class StableDiffusionGGML {
3278
3281
3279
3282
struct ggml_tensor * hidden_states = cond_stage_model.text_model .forward (ctx, input_ids);
3280
3283
3281
- struct ggml_cgraph cond_graph = ggml_build_forward ( hidden_states);
3282
- struct ggml_cplan cplan = ggml_graph_plan (& cond_graph, n_threads);
3284
+ struct ggml_cgraph * cond_graph = ggml_build_forward_ctx (ctx, hidden_states);
3285
+ cplan = ggml_graph_plan (cond_graph, n_threads);
3283
3286
ctx_size += cplan.work_size ;
3284
3287
3285
3288
ctx_size += ggml_used_mem (ctx) + ggml_used_mem_of_data (ctx);
@@ -3390,6 +3393,7 @@ class StableDiffusionGGML {
3390
3393
// print_ggml_tensor(x_t);
3391
3394
struct ggml_tensor * x = ggml_dup_tensor (res_ctx, x_t );
3392
3395
copy_ggml_tensor (x, x_t );
3396
+ struct ggml_cplan cplan;
3393
3397
3394
3398
size_t ctx_size = 10 * 1024 * 1024 ; // 10MB
3395
3399
// calculate the amount of memory required
@@ -3417,7 +3421,7 @@ class StableDiffusionGGML {
3417
3421
ctx_size += ggml_used_mem (ctx) + ggml_used_mem_of_data (ctx);
3418
3422
3419
3423
struct ggml_cgraph * diffusion_graph = ggml_build_forward_ctx (ctx, out);
3420
- struct ggml_cplan cplan = ggml_graph_plan (diffusion_graph, n_threads);
3424
+ cplan = ggml_graph_plan (diffusion_graph, n_threads);
3421
3425
3422
3426
ctx_size += cplan.work_size ;
3423
3427
LOG_DEBUG (" diffusion context need %.2fMB static memory, with work_size needing %.2fMB" ,
@@ -3450,7 +3454,7 @@ class StableDiffusionGGML {
3450
3454
ggml_hold_dynamic_tensor (out);
3451
3455
3452
3456
struct ggml_cgraph * diffusion_graph = ggml_build_forward_ctx (ctx, out);
3453
- struct ggml_cplan cplan = ggml_graph_plan (diffusion_graph, n_threads);
3457
+ cplan = ggml_graph_plan (diffusion_graph, n_threads);
3454
3458
3455
3459
ggml_set_dynamic (ctx, false );
3456
3460
struct ggml_tensor * buf = ggml_new_tensor_1d (ctx, GGML_TYPE_I8, cplan.work_size );
@@ -3961,6 +3965,7 @@ class StableDiffusionGGML {
3961
3965
int64_t W = x->ne [0 ];
3962
3966
int64_t H = x->ne [1 ];
3963
3967
struct ggml_tensor * result = NULL ;
3968
+ struct ggml_cplan cplan;
3964
3969
3965
3970
// calculate the amount of memory required
3966
3971
size_t ctx_size = 10 * 1024 * 1024 ; // 10MB
@@ -3981,7 +3986,7 @@ class StableDiffusionGGML {
3981
3986
ctx_size += ggml_used_mem (ctx) + ggml_used_mem_of_data (ctx);
3982
3987
3983
3988
struct ggml_cgraph * vae_graph = ggml_build_forward_ctx (ctx, moments);
3984
- struct ggml_cplan cplan = ggml_graph_plan (vae_graph, n_threads);
3989
+ cplan = ggml_graph_plan (vae_graph, n_threads);
3985
3990
3986
3991
ctx_size += cplan.work_size ;
3987
3992
LOG_DEBUG (" vae context need %.2fMB static memory, with work_size needing %.2fMB" ,
@@ -4083,6 +4088,7 @@ class StableDiffusionGGML {
4083
4088
int64_t W = z->ne [0 ];
4084
4089
int64_t H = z->ne [1 ];
4085
4090
struct ggml_tensor * result_img = NULL ;
4091
+ struct ggml_cplan cplan;
4086
4092
4087
4093
{
4088
4094
float * vec = (float *)z->data ;
@@ -4110,7 +4116,7 @@ class StableDiffusionGGML {
4110
4116
ctx_size += ggml_used_mem (ctx) + ggml_used_mem_of_data (ctx);
4111
4117
4112
4118
struct ggml_cgraph * vae_graph = ggml_build_forward_ctx (ctx, img);
4113
- struct ggml_cplan cplan = ggml_graph_plan (vae_graph, n_threads);
4119
+ cplan = ggml_graph_plan (vae_graph, n_threads);
4114
4120
4115
4121
ctx_size += cplan.work_size ;
4116
4122
LOG_DEBUG (" vae context need %.2fMB static memory, with work_size needing %.2fMB" ,
0 commit comments