@@ -350,69 +350,69 @@ std::string convert_diffusers_name_to_compvis(std::string key, char seq) {
350
350
351
351
// convert attn to out
352
352
if (ends_with (key, " to_out" )) {
353
- key += format (" %c0" , seq);
353
+ key += sd_format (" %c0" , seq);
354
354
}
355
355
356
356
// unet
357
- if (match (m, std::regex (format (" unet%cconv_in(.*)" , seq)), key)) {
358
- return format (" model%cdiffusion_model%cinput_blocks%c0%c0" , seq, seq, seq, seq) + m[0 ];
357
+ if (match (m, std::regex (sd_format (" unet%cconv_in(.*)" , seq)), key)) {
358
+ return sd_format (" model%cdiffusion_model%cinput_blocks%c0%c0" , seq, seq, seq, seq) + m[0 ];
359
359
}
360
360
361
- if (match (m, std::regex (format (" unet%cconv%cout(.*)" , seq, seq)), key)) {
362
- return format (" model%cdiffusion_model%cout%c2" , seq, seq, seq) + m[0 ];
361
+ if (match (m, std::regex (sd_format (" unet%cconv%cout(.*)" , seq, seq)), key)) {
362
+ return sd_format (" model%cdiffusion_model%cout%c2" , seq, seq, seq) + m[0 ];
363
363
}
364
364
365
- if (match (m, std::regex (format (" unet%cconv_norm_out(.*)" , seq)), key)) {
366
- return format (" model%cdiffusion_model%cout%c0" , seq, seq, seq) + m[0 ];
365
+ if (match (m, std::regex (sd_format (" unet%cconv_norm_out(.*)" , seq)), key)) {
366
+ return sd_format (" model%cdiffusion_model%cout%c0" , seq, seq, seq) + m[0 ];
367
367
}
368
368
369
- if (match (m, std::regex (format (" unet%ctime_embedding%clinear_(\\ d+)(.*)" , seq, seq)), key)) {
370
- return format (" model%cdiffusion_model%ctime_embed%c" , seq, seq, seq) + std::to_string (std::stoi (m[0 ]) * 2 - 2 ) + m[1 ];
369
+ if (match (m, std::regex (sd_format (" unet%ctime_embedding%clinear_(\\ d+)(.*)" , seq, seq)), key)) {
370
+ return sd_format (" model%cdiffusion_model%ctime_embed%c" , seq, seq, seq) + std::to_string (std::stoi (m[0 ]) * 2 - 2 ) + m[1 ];
371
371
}
372
372
373
- if (match (m, std::regex (format (" unet%cdown_blocks%c(\\ d+)%c(attentions|resnets)%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq)), key)) {
373
+ if (match (m, std::regex (sd_format (" unet%cdown_blocks%c(\\ d+)%c(attentions|resnets)%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq)), key)) {
374
374
std::string suffix = get_converted_suffix (m[1 ], m[3 ]);
375
375
// LOG_DEBUG("%s %s %s %s", m[0].c_str(), m[1].c_str(), m[2].c_str(), m[3].c_str());
376
- return format (" model%cdiffusion_model%cinput_blocks%c" , seq, seq, seq) + std::to_string (1 + std::stoi (m[0 ]) * 3 + std::stoi (m[2 ])) + seq +
376
+ return sd_format (" model%cdiffusion_model%cinput_blocks%c" , seq, seq, seq) + std::to_string (1 + std::stoi (m[0 ]) * 3 + std::stoi (m[2 ])) + seq +
377
377
(m[1 ] == " attentions" ? " 1" : " 0" ) + seq + suffix;
378
378
}
379
379
380
- if (match (m, std::regex (format (" unet%cmid_block%c(attentions|resnets)%c(\\ d+)%c(.+)" , seq, seq, seq, seq)), key)) {
380
+ if (match (m, std::regex (sd_format (" unet%cmid_block%c(attentions|resnets)%c(\\ d+)%c(.+)" , seq, seq, seq, seq)), key)) {
381
381
std::string suffix = get_converted_suffix (m[0 ], m[2 ]);
382
- return format (" model%cdiffusion_model%cmiddle_block%c" , seq, seq, seq) + (m[0 ] == " attentions" ? " 1" : std::to_string (std::stoi (m[1 ]) * 2 )) +
382
+ return sd_format (" model%cdiffusion_model%cmiddle_block%c" , seq, seq, seq) + (m[0 ] == " attentions" ? " 1" : std::to_string (std::stoi (m[1 ]) * 2 )) +
383
383
seq + suffix;
384
384
}
385
385
386
- if (match (m, std::regex (format (" unet%cup_blocks%c(\\ d+)%c(attentions|resnets)%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq)), key)) {
386
+ if (match (m, std::regex (sd_format (" unet%cup_blocks%c(\\ d+)%c(attentions|resnets)%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq)), key)) {
387
387
std::string suffix = get_converted_suffix (m[1 ], m[3 ]);
388
- return format (" model%cdiffusion_model%coutput_blocks%c" , seq, seq, seq) + std::to_string (std::stoi (m[0 ]) * 3 + std::stoi (m[2 ])) + seq +
388
+ return sd_format (" model%cdiffusion_model%coutput_blocks%c" , seq, seq, seq) + std::to_string (std::stoi (m[0 ]) * 3 + std::stoi (m[2 ])) + seq +
389
389
(m[1 ] == " attentions" ? " 1" : " 0" ) + seq + suffix;
390
390
}
391
391
392
- if (match (m, std::regex (format (" unet%cdown_blocks%c(\\ d+)%cdownsamplers%c0%cconv" , seq, seq, seq, seq, seq)), key)) {
393
- return format (" model%cdiffusion_model%cinput_blocks%c" , seq, seq, seq) + std::to_string (3 + std::stoi (m[0 ]) * 3 ) + seq + " 0" + seq + " op" ;
392
+ if (match (m, std::regex (sd_format (" unet%cdown_blocks%c(\\ d+)%cdownsamplers%c0%cconv" , seq, seq, seq, seq, seq)), key)) {
393
+ return sd_format (" model%cdiffusion_model%cinput_blocks%c" , seq, seq, seq) + std::to_string (3 + std::stoi (m[0 ]) * 3 ) + seq + " 0" + seq + " op" ;
394
394
}
395
395
396
- if (match (m, std::regex (format (" unet%cup_blocks%c(\\ d+)%cupsamplers%c0%cconv" , seq, seq, seq, seq, seq)), key)) {
397
- return format (" model%cdiffusion_model%coutput_blocks%c" , seq, seq, seq) + std::to_string (2 + std::stoi (m[0 ]) * 3 ) + seq +
396
+ if (match (m, std::regex (sd_format (" unet%cup_blocks%c(\\ d+)%cupsamplers%c0%cconv" , seq, seq, seq, seq, seq)), key)) {
397
+ return sd_format (" model%cdiffusion_model%coutput_blocks%c" , seq, seq, seq) + std::to_string (2 + std::stoi (m[0 ]) * 3 ) + seq +
398
398
(std::stoi (m[0 ]) > 0 ? " 2" : " 1" ) + seq + " conv" ;
399
399
}
400
400
401
401
// clip
402
- if (match (m, std::regex (format (" te%ctext_model%cencoder%clayers%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq)), key)) {
403
- return format (" cond_stage_model%ctransformer%ctext_model%cencoder%clayers%c" , seq, seq, seq, seq, seq) + m[0 ] + seq + m[1 ];
402
+ if (match (m, std::regex (sd_format (" te%ctext_model%cencoder%clayers%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq)), key)) {
403
+ return sd_format (" cond_stage_model%ctransformer%ctext_model%cencoder%clayers%c" , seq, seq, seq, seq, seq) + m[0 ] + seq + m[1 ];
404
404
}
405
405
406
- if (match (m, std::regex (format (" te%ctext_model(.*)" , seq)), key)) {
407
- return format (" cond_stage_model%ctransformer%ctext_model" , seq, seq) + m[0 ];
406
+ if (match (m, std::regex (sd_format (" te%ctext_model(.*)" , seq)), key)) {
407
+ return sd_format (" cond_stage_model%ctransformer%ctext_model" , seq, seq) + m[0 ];
408
408
}
409
409
410
410
// vae
411
- if (match (m, std::regex (format (" vae%c(.*)%cconv_norm_out(.*)" , seq, seq)), key)) {
412
- return format (" first_stage_model%c%s%cnorm_out%s" , seq, m[0 ].c_str (), seq, m[1 ].c_str ());
411
+ if (match (m, std::regex (sd_format (" vae%c(.*)%cconv_norm_out(.*)" , seq, seq)), key)) {
412
+ return sd_format (" first_stage_model%c%s%cnorm_out%s" , seq, m[0 ].c_str (), seq, m[1 ].c_str ());
413
413
}
414
414
415
- if (match (m, std::regex (format (" vae%c(.*)%cmid_block%c(attentions|resnets)%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq)), key)) {
415
+ if (match (m, std::regex (sd_format (" vae%c(.*)%cmid_block%c(attentions|resnets)%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq)), key)) {
416
416
std::string suffix;
417
417
std::string block_name;
418
418
if (m[1 ] == " attentions" ) {
@@ -422,40 +422,40 @@ std::string convert_diffusers_name_to_compvis(std::string key, char seq) {
422
422
block_name = " block" ;
423
423
suffix = m[3 ];
424
424
}
425
- return format (" first_stage_model%c%s%cmid%c%s_%d%c%s" ,
425
+ return sd_format (" first_stage_model%c%s%cmid%c%s_%d%c%s" ,
426
426
seq, m[0 ].c_str (), seq, seq, block_name.c_str (), std::stoi (m[2 ]) + 1 , seq, suffix.c_str ());
427
427
}
428
428
429
- if (match (m, std::regex (format (" vae%c(.*)%cup_blocks%c(\\ d+)%cresnets%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq, seq)), key)) {
429
+ if (match (m, std::regex (sd_format (" vae%c(.*)%cup_blocks%c(\\ d+)%cresnets%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq, seq)), key)) {
430
430
std::string suffix = m[3 ];
431
431
if (suffix == " conv_shortcut" ) {
432
432
suffix = " nin_shortcut" ;
433
433
}
434
- return format (" first_stage_model%c%s%cup%c%d%cblock%c%s%c%s" ,
434
+ return sd_format (" first_stage_model%c%s%cup%c%d%cblock%c%s%c%s" ,
435
435
seq, m[0 ].c_str (), seq, seq, 3 - std::stoi (m[1 ]), seq, seq, m[2 ].c_str (), seq, suffix.c_str ());
436
436
}
437
437
438
- if (match (m, std::regex (format (" vae%c(.*)%cdown_blocks%c(\\ d+)%cdownsamplers%c0%cconv" , seq, seq, seq, seq, seq, seq)), key)) {
439
- return format (" first_stage_model%c%s%cdown%c%d%cdownsample%cconv" ,
438
+ if (match (m, std::regex (sd_format (" vae%c(.*)%cdown_blocks%c(\\ d+)%cdownsamplers%c0%cconv" , seq, seq, seq, seq, seq, seq)), key)) {
439
+ return sd_format (" first_stage_model%c%s%cdown%c%d%cdownsample%cconv" ,
440
440
seq, m[0 ].c_str (), seq, seq, std::stoi (m[1 ]), seq, seq);
441
441
}
442
442
443
- if (match (m, std::regex (format (" vae%c(.*)%cdown_blocks%c(\\ d+)%cresnets%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq, seq)), key)) {
443
+ if (match (m, std::regex (sd_format (" vae%c(.*)%cdown_blocks%c(\\ d+)%cresnets%c(\\ d+)%c(.+)" , seq, seq, seq, seq, seq, seq)), key)) {
444
444
std::string suffix = m[3 ];
445
445
if (suffix == " conv_shortcut" ) {
446
446
suffix = " nin_shortcut" ;
447
447
}
448
- return format (" first_stage_model%c%s%cdown%c%d%cblock%c%s%c%s" ,
448
+ return sd_format (" first_stage_model%c%s%cdown%c%d%cblock%c%s%c%s" ,
449
449
seq, m[0 ].c_str (), seq, seq, std::stoi (m[1 ]), seq, seq, m[2 ].c_str (), seq, suffix.c_str ());
450
450
}
451
451
452
- if (match (m, std::regex (format (" vae%c(.*)%cup_blocks%c(\\ d+)%cupsamplers%c0%cconv" , seq, seq, seq, seq, seq, seq)), key)) {
453
- return format (" first_stage_model%c%s%cup%c%d%cupsample%cconv" ,
452
+ if (match (m, std::regex (sd_format (" vae%c(.*)%cup_blocks%c(\\ d+)%cupsamplers%c0%cconv" , seq, seq, seq, seq, seq, seq)), key)) {
453
+ return sd_format (" first_stage_model%c%s%cup%c%d%cupsample%cconv" ,
454
454
seq, m[0 ].c_str (), seq, seq, 3 - std::stoi (m[1 ]), seq, seq);
455
455
}
456
456
457
- if (match (m, std::regex (format (" vae%c(.*)" , seq)), key)) {
458
- return format (" first_stage_model%c" , seq) + m[0 ];
457
+ if (match (m, std::regex (sd_format (" vae%c(.*)" , seq)), key)) {
458
+ return sd_format (" first_stage_model%c" , seq) + m[0 ];
459
459
}
460
460
461
461
return key;
@@ -756,7 +756,7 @@ void convert_tensor(void* src,
756
756
} else {
757
757
auto qtype = ggml_get_type_traits (src_type);
758
758
if (qtype->to_float == NULL ) {
759
- throw std::runtime_error (format (" type %s unsupported for integer quantization: no dequantization available" ,
759
+ throw std::runtime_error (sd_format (" type %s unsupported for integer quantization: no dequantization available" ,
760
760
ggml_type_name (src_type)));
761
761
}
762
762
qtype->to_float (src, (float *)dst, n);
@@ -766,7 +766,7 @@ void convert_tensor(void* src,
766
766
// src_type is quantized => dst_type == GGML_TYPE_F16 or dst_type is quantized
767
767
auto qtype = ggml_get_type_traits (src_type);
768
768
if (qtype->to_float == NULL ) {
769
- throw std::runtime_error (format (" type %s unsupported for integer quantization: no dequantization available" ,
769
+ throw std::runtime_error (sd_format (" type %s unsupported for integer quantization: no dequantization available" ,
770
770
ggml_type_name (src_type)));
771
771
}
772
772
std::vector<char > buf;
0 commit comments