Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ bool convert(const char* input_path,
model_loader.convert_tensors_name();
}

ggml_type type = (ggml_type)output_type;
ggml_type type = sd_type_to_ggml(output_type);
bool output_is_safetensors = ends_with(output_path, ".safetensors");
TensorTypeRules type_rules = parse_tensor_type_rules(tensor_type_rules);

Expand Down
4 changes: 1 addition & 3 deletions src/stable-diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,7 @@ class StableDiffusionGGML {
auto& tensor_storage_map = model_loader.get_tensor_storage_map();

LOG_INFO("Version: %s ", model_version_to_str[version]);
ggml_type wtype = (int)sd_ctx_params->wtype < std::min<int>(SD_TYPE_COUNT, GGML_TYPE_COUNT)
? (ggml_type)sd_ctx_params->wtype
: GGML_TYPE_COUNT;
ggml_type wtype = sd_type_to_ggml(sd_ctx_params->wtype);
std::string tensor_type_rules = SAFE_STR(sd_ctx_params->tensor_type_rules);
if (wtype != GGML_TYPE_COUNT || tensor_type_rules.size() > 0) {
model_loader.set_wtype_override(wtype, tensor_type_rules);
Expand Down
9 changes: 9 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,15 @@ std::vector<std::string> split_string(const std::string& str, char delimiter) {
return result;
}

ggml_type sd_type_to_ggml(sd_type_t sdtype) {
const int type_value = static_cast<int>(sdtype);
if (type_value < std::min<int>(SD_TYPE_COUNT, GGML_TYPE_COUNT)) {
return static_cast<ggml_type>(type_value);
} else {
return GGML_TYPE_COUNT;
}
}

static std::string build_progress_bar(int step, int steps) {
std::string progress = " |";
int max_progress = 50;
Expand Down
2 changes: 2 additions & 0 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ void pretty_bytes_progress(int step, int steps, uint64_t bytes_processed, float

void log_printf(sd_log_level_t level, const char* file, int line, const char* format, ...);

ggml_type sd_type_to_ggml(sd_type_t sdtype);

std::string trim(const std::string& s);

std::vector<std::pair<std::string, float>> parse_prompt_attention(const std::string& text);
Expand Down
Loading