Skip to content

Commit c288969

Browse files
committed
fix: sd3.5 large
Signed-off-by: thxCode <thxcode0824@gmail.com>
1 parent 4b01866 commit c288969

File tree

4 files changed

+12
-22
lines changed

4 files changed

+12
-22
lines changed

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,14 +111,13 @@ if(SD_SYCL)
111111
target_compile_options(${SD_LIB} PRIVATE ${SYCL_COMPILE_OPTIONS})
112112
endif()
113113

114-
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
115-
116114
# see https://github.com/ggerganov/ggml/pull/682
117115
add_definitions(-DGGML_MAX_NAME=128)
118116

119117
# deps
120118
# Only add ggml if it hasn't been added yet
121119
if (NOT TARGET ggml)
120+
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
122121
add_subdirectory(ggml)
123122
endif()
124123

examples/convert/main.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static bool convert_params_parse(int argc, char** argv, convert_params& params)
139139
}
140140
const char* outtype = argv[i++];
141141
params.vae_output_type = convert_str_to_ggml_type(outtype);
142-
if (params.vae_output_type == GGML_TYPE_COUNT) {
142+
if (params.vae_output_type >= GGML_TYPE_COUNT) {
143143
invalid("--vae-outtype");
144144
}
145145
continue;
@@ -151,7 +151,7 @@ static bool convert_params_parse(int argc, char** argv, convert_params& params)
151151
}
152152
const char* outtype = argv[i++];
153153
params.clip_output_type = convert_str_to_ggml_type(outtype);
154-
if (params.clip_output_type == GGML_TYPE_COUNT) {
154+
if (params.clip_output_type >= GGML_TYPE_COUNT) {
155155
invalid("--clip-outtype");
156156
}
157157
continue;
@@ -163,7 +163,7 @@ static bool convert_params_parse(int argc, char** argv, convert_params& params)
163163
}
164164
const char* outtype = argv[i++];
165165
params.output_type = convert_str_to_ggml_type(outtype);
166-
if (params.output_type == GGML_TYPE_COUNT) {
166+
if (params.output_type >= GGML_TYPE_COUNT) {
167167
invalid("--outtype");
168168
}
169169
continue;

model.cpp

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1566,20 +1566,7 @@ SDVersion ModelLoader::get_sd_version() {
15661566
}
15671567

15681568
ggml_type ModelLoader::get_sd_wtype() {
1569-
for (auto& tensor_storage : tensor_storages) {
1570-
if (is_unused_tensor(tensor_storage.name)) {
1571-
continue;
1572-
}
1573-
1574-
if (ggml_is_quantized(tensor_storage.type)) {
1575-
return tensor_storage.type;
1576-
}
1577-
1578-
if (tensor_should_be_converted(tensor_storage, GGML_TYPE_Q4_K)) {
1579-
return tensor_storage.type;
1580-
}
1581-
}
1582-
return GGML_TYPE_COUNT;
1569+
return get_diffusion_model_wtype();
15831570
}
15841571

15851572
ggml_type ModelLoader::get_conditioner_wtype() {
@@ -1962,13 +1949,17 @@ bool ModelLoader::tensor_should_be_converted(const TensorStorage& tensor_storage
19621949
}
19631950

19641951
bool ModelLoader::save_to_gguf_file(const std::string& file_path, ggml_type outtype, ggml_type vae_outtype, ggml_type clip_outtype) {
1965-
if (vae_outtype == GGML_TYPE_COUNT) {
1952+
if (vae_outtype >= GGML_TYPE_COUNT) {
19661953
vae_outtype = outtype;
19671954
}
1968-
if (clip_outtype == GGML_TYPE_COUNT) {
1955+
if (clip_outtype >= GGML_TYPE_COUNT) {
19691956
clip_outtype = outtype;
19701957
}
19711958

1959+
LOG_INFO("save conditioner weight type: %s", ggml_type_name(clip_outtype));
1960+
LOG_INFO("save diffusion model weight type: %s", ggml_type_name(outtype));
1961+
LOG_INFO("save vae weight type: %s", ggml_type_name(vae_outtype));
1962+
19721963
auto backend = ggml_backend_cpu_init();
19731964
size_t mem_size = 1 * 1024 * 1024; // for padding
19741965
mem_size += tensor_storages.size() * ggml_tensor_overhead();

stable-diffusion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ class StableDiffusionGGML {
283283
model_wtype = model_loader.get_sd_wtype();
284284
if (model_wtype == GGML_TYPE_COUNT) {
285285
model_wtype = GGML_TYPE_F32;
286-
LOG_WARN("can not get mode wtype frome weight, use f32");
286+
LOG_WARN("can not get mode wtype from weight, use f32");
287287
}
288288
conditioner_wtype = model_loader.get_conditioner_wtype();
289289
if (conditioner_wtype == GGML_TYPE_COUNT) {

0 commit comments

Comments
 (0)