@@ -48,7 +48,6 @@ struct FrozenCLIPEmbedderWithCustomWords : public Conditioner {
48
48
SDVersion version = VERSION_SD1;
49
49
PMVersion pm_version = PM_VERSION_1;
50
50
CLIPTokenizer tokenizer;
51
- ggml_type wtype;
52
51
std::shared_ptr<CLIPTextModelRunner> text_model;
53
52
std::shared_ptr<CLIPTextModelRunner> text_model2;
54
53
@@ -59,7 +58,8 @@ struct FrozenCLIPEmbedderWithCustomWords : public Conditioner {
59
58
std::vector<std::string> readed_embeddings;
60
59
61
60
FrozenCLIPEmbedderWithCustomWords (ggml_backend_t backend,
62
- ggml_type wtype,
61
+ ggml_type clip_l_wtype,
62
+ ggml_type clip_g_wtype,
63
63
const std::string& embd_dir,
64
64
SDVersion version = VERSION_SD1,
65
65
PMVersion pv = PM_VERSION_1,
@@ -70,7 +70,6 @@ struct FrozenCLIPEmbedderWithCustomWords : public Conditioner {
70
70
pm_version (pv),
71
71
tokenizer(version == VERSION_SD2 ? 0 : 49407 ),
72
72
embd_dir(embd_dir),
73
- wtype(wtype),
74
73
compvis_compatiblity_clip_l(compvis_compatiblity_clip_l),
75
74
compvis_compatiblity_clip_g(compvis_compatiblity_clip_g) {
76
75
if (clip_skip <= 0 ) {
@@ -80,14 +79,14 @@ struct FrozenCLIPEmbedderWithCustomWords : public Conditioner {
80
79
}
81
80
}
82
81
if (version == VERSION_SD1) {
83
- text_model = std::make_shared<CLIPTextModelRunner>(backend, wtype , OPENAI_CLIP_VIT_L_14, clip_skip);
82
+ text_model = std::make_shared<CLIPTextModelRunner>(backend, clip_l_wtype , OPENAI_CLIP_VIT_L_14, clip_skip);
84
83
} else if (version == VERSION_SD2) {
85
- text_model = std::make_shared<CLIPTextModelRunner>(backend, wtype , OPEN_CLIP_VIT_H_14, clip_skip);
84
+ text_model = std::make_shared<CLIPTextModelRunner>(backend, clip_l_wtype , OPEN_CLIP_VIT_H_14, clip_skip);
86
85
} else if (version == VERSION_SDXL) {
87
- text_model = std::make_shared<CLIPTextModelRunner>(backend, wtype , OPENAI_CLIP_VIT_L_14, clip_skip, false );
88
- text_model2 = std::make_shared<CLIPTextModelRunner>(backend, wtype , OPEN_CLIP_VIT_BIGG_14, clip_skip, false );
86
+ text_model = std::make_shared<CLIPTextModelRunner>(backend, clip_l_wtype , OPENAI_CLIP_VIT_L_14, clip_skip, false );
87
+ text_model2 = std::make_shared<CLIPTextModelRunner>(backend, clip_g_wtype , OPEN_CLIP_VIT_BIGG_14, clip_skip, false );
89
88
} else if (version == VERSION_SDXL_REFINER) {
90
- text_model2 = std::make_shared<CLIPTextModelRunner>(backend, wtype , OPEN_CLIP_VIT_BIGG_14, clip_skip, false );
89
+ text_model2 = std::make_shared<CLIPTextModelRunner>(backend, clip_g_wtype , OPEN_CLIP_VIT_BIGG_14, clip_skip, false );
91
90
}
92
91
}
93
92
@@ -174,14 +173,14 @@ struct FrozenCLIPEmbedderWithCustomWords : public Conditioner {
174
173
LOG_DEBUG (" embedding wrong hidden size, got %i, expected %i" , tensor_storage.ne [0 ], hidden_size);
175
174
return false ;
176
175
}
177
- embd = ggml_new_tensor_2d (embd_ctx, wtype , hidden_size, tensor_storage.n_dims > 1 ? tensor_storage.ne [1 ] : 1 );
176
+ embd = ggml_new_tensor_2d (embd_ctx, tensor_storage. type , hidden_size, tensor_storage.n_dims > 1 ? tensor_storage.ne [1 ] : 1 );
178
177
*dst_tensor = embd;
179
178
return true ;
180
179
};
181
180
model_loader.load_tensors (on_load, NULL );
182
181
readed_embeddings.push_back (embd_name);
183
182
token_embed_custom.resize (token_embed_custom.size () + ggml_nbytes (embd));
184
- memcpy ((void *)(token_embed_custom.data () + num_custom_embeddings * hidden_size * ggml_type_size (wtype )),
183
+ memcpy ((void *)(token_embed_custom.data () + num_custom_embeddings * hidden_size * ggml_type_size (embd-> type )),
185
184
embd->data ,
186
185
ggml_nbytes (embd));
187
186
for (int i = 0 ; i < embd->ne [1 ]; i++) {
@@ -674,7 +673,6 @@ struct SD3CLIPEmbedder : public Conditioner {
674
673
bool compvis_compatiblity_clip_l;
675
674
bool compvis_compatiblity_clip_g;
676
675
bool compvis_compatiblity_t5xxl;
677
- ggml_type wtype;
678
676
CLIPTokenizer clip_l_tokenizer;
679
677
CLIPTokenizer clip_g_tokenizer;
680
678
T5UniGramTokenizer t5_tokenizer;
@@ -683,22 +681,23 @@ struct SD3CLIPEmbedder : public Conditioner {
683
681
std::shared_ptr<T5Runner> t5;
684
682
685
683
SD3CLIPEmbedder (ggml_backend_t backend,
686
- ggml_type wtype,
684
+ ggml_type clip_l_wtype,
685
+ ggml_type clip_g_wtype,
686
+ ggml_type t5xxl_wtype,
687
687
bool compvis_compatiblity_clip_l = false ,
688
688
bool compvis_compatiblity_clip_g = false ,
689
689
bool compvis_compatiblity_t5xxl = false ,
690
690
int clip_skip = -1 )
691
- : wtype(wtype),
692
- clip_g_tokenizer (0 ),
691
+ : clip_g_tokenizer(0 ),
693
692
compvis_compatiblity_clip_l (compvis_compatiblity_clip_l),
694
693
compvis_compatiblity_clip_g(compvis_compatiblity_clip_g),
695
694
compvis_compatiblity_t5xxl(compvis_compatiblity_t5xxl) {
696
695
if (clip_skip <= 0 ) {
697
696
clip_skip = 2 ;
698
697
}
699
- clip_l = std::make_shared<CLIPTextModelRunner>(backend, wtype , OPENAI_CLIP_VIT_L_14, clip_skip, false );
700
- clip_g = std::make_shared<CLIPTextModelRunner>(backend, wtype , OPEN_CLIP_VIT_BIGG_14, clip_skip, false );
701
- t5 = std::make_shared<T5Runner>(backend, wtype );
698
+ clip_l = std::make_shared<CLIPTextModelRunner>(backend, clip_l_wtype , OPENAI_CLIP_VIT_L_14, clip_skip, false );
699
+ clip_g = std::make_shared<CLIPTextModelRunner>(backend, clip_g_wtype , OPEN_CLIP_VIT_BIGG_14, clip_skip, false );
700
+ t5 = std::make_shared<T5Runner>(backend, t5xxl_wtype );
702
701
}
703
702
704
703
void set_clip_skip (int clip_skip) {
@@ -1042,25 +1041,24 @@ struct SD3CLIPEmbedder : public Conditioner {
1042
1041
struct FluxCLIPEmbedder : public Conditioner {
1043
1042
bool compvis_compatiblity_clip_l;
1044
1043
bool compvis_compatiblity_t5xxl;
1045
- ggml_type wtype;
1046
1044
CLIPTokenizer clip_l_tokenizer;
1047
1045
T5UniGramTokenizer t5_tokenizer;
1048
1046
std::shared_ptr<CLIPTextModelRunner> clip_l;
1049
1047
std::shared_ptr<T5Runner> t5;
1050
1048
1051
1049
FluxCLIPEmbedder (ggml_backend_t backend,
1052
- ggml_type wtype,
1050
+ ggml_type clip_l_wtype,
1051
+ ggml_type t5xxl_wtype,
1053
1052
bool compvis_compatiblity_clip_l = false ,
1054
1053
bool compvis_compatiblity_t5xxl = false ,
1055
1054
int clip_skip = -1 )
1056
- : wtype(wtype),
1057
- compvis_compatiblity_clip_l (compvis_compatiblity_clip_l),
1055
+ : compvis_compatiblity_clip_l(compvis_compatiblity_clip_l),
1058
1056
compvis_compatiblity_t5xxl (compvis_compatiblity_t5xxl) {
1059
1057
if (clip_skip <= 0 ) {
1060
1058
clip_skip = 2 ;
1061
1059
}
1062
- clip_l = std::make_shared<CLIPTextModelRunner>(backend, wtype , OPENAI_CLIP_VIT_L_14, clip_skip, true );
1063
- t5 = std::make_shared<T5Runner>(backend, wtype );
1060
+ clip_l = std::make_shared<CLIPTextModelRunner>(backend, clip_l_wtype , OPENAI_CLIP_VIT_L_14, clip_skip, true );
1061
+ t5 = std::make_shared<T5Runner>(backend, t5xxl_wtype );
1064
1062
}
1065
1063
1066
1064
void set_clip_skip (int clip_skip) {
0 commit comments