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
43 changes: 16 additions & 27 deletions model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1908,18 +1908,22 @@ SDVersion ModelLoader::get_sd_version() {
return VERSION_COUNT;
}

std::map<ggml_type, uint32_t> ModelLoader::get_wtype_stat() {
std::map<ggml_type, uint32_t> ModelLoader::get_loaded_wtype_stat() {
std::map<ggml_type, uint32_t> wtype_stat;
for (auto& tensor_storage : tensor_storages) {
if (is_unused_tensor(tensor_storage.name)) {
continue;
for (auto& pair : tensor_storages_types) {
if (!is_unused_tensor(pair.first)) {
wtype_stat[pair.second]++;
}
}

auto iter = wtype_stat.find(tensor_storage.type);
if (iter != wtype_stat.end()) {
iter->second++;
} else {
wtype_stat[tensor_storage.type] = 1;
return wtype_stat;
}

std::map<ggml_type, uint32_t> ModelLoader::get_wtype_stat() {
std::map<ggml_type, uint32_t> wtype_stat;
for (auto& tensor_storage : tensor_storages) {
if (!is_unused_tensor(tensor_storage.name)) {
wtype_stat[tensor_storage.type]++;
}
}
return wtype_stat;
Expand All @@ -1939,12 +1943,7 @@ std::map<ggml_type, uint32_t> ModelLoader::get_conditioner_wtype_stat() {
continue;
}

auto iter = wtype_stat.find(tensor_storage.type);
if (iter != wtype_stat.end()) {
iter->second++;
} else {
wtype_stat[tensor_storage.type] = 1;
}
wtype_stat[tensor_storage.type]++;
}
return wtype_stat;
}
Expand All @@ -1960,12 +1959,7 @@ std::map<ggml_type, uint32_t> ModelLoader::get_diffusion_model_wtype_stat() {
continue;
}

auto iter = wtype_stat.find(tensor_storage.type);
if (iter != wtype_stat.end()) {
iter->second++;
} else {
wtype_stat[tensor_storage.type] = 1;
}
wtype_stat[tensor_storage.type]++;
}
return wtype_stat;
}
Expand All @@ -1982,12 +1976,7 @@ std::map<ggml_type, uint32_t> ModelLoader::get_vae_wtype_stat() {
continue;
}

auto iter = wtype_stat.find(tensor_storage.type);
if (iter != wtype_stat.end()) {
iter->second++;
} else {
wtype_stat[tensor_storage.type] = 1;
}
wtype_stat[tensor_storage.type]++;
}
return wtype_stat;
}
Expand Down
1 change: 1 addition & 0 deletions model.h
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class ModelLoader {
bool init_from_file(const std::string& file_path, const std::string& prefix = "");
bool model_is_unet();
SDVersion get_sd_version();
std::map<ggml_type, uint32_t> get_loaded_wtype_stat();
std::map<ggml_type, uint32_t> get_wtype_stat();
std::map<ggml_type, uint32_t> get_conditioner_wtype_stat();
std::map<ggml_type, uint32_t> get_diffusion_model_wtype_stat();
Expand Down
14 changes: 5 additions & 9 deletions stable-diffusion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,11 +298,6 @@ class StableDiffusionGGML {
model_loader.set_wtype_override(wtype);
}

std::map<ggml_type, uint32_t> wtype_stat = model_loader.get_wtype_stat();
std::map<ggml_type, uint32_t> conditioner_wtype_stat = model_loader.get_conditioner_wtype_stat();
std::map<ggml_type, uint32_t> diffusion_model_wtype_stat = model_loader.get_diffusion_model_wtype_stat();
std::map<ggml_type, uint32_t> vae_wtype_stat = model_loader.get_vae_wtype_stat();

auto wtype_stat_to_str = [](const std::map<ggml_type, uint32_t>& m, int key_width = 8, int value_width = 5) -> std::string {
std::ostringstream oss;
bool first = true;
Expand All @@ -317,10 +312,11 @@ class StableDiffusionGGML {
return oss.str();
};

LOG_INFO("Weight type stat: %s", wtype_stat_to_str(wtype_stat).c_str());
LOG_INFO("Conditioner weight type stat: %s", wtype_stat_to_str(conditioner_wtype_stat).c_str());
LOG_INFO("Diffusion model weight type stat: %s", wtype_stat_to_str(diffusion_model_wtype_stat).c_str());
LOG_INFO("VAE weight type stat: %s", wtype_stat_to_str(vae_wtype_stat).c_str());
LOG_INFO("Loaded weight type stat: %s", wtype_stat_to_str(model_loader.get_loaded_wtype_stat()).c_str());
LOG_INFO("Weight type stat: %s", wtype_stat_to_str(model_loader.get_wtype_stat()).c_str());
LOG_INFO("Conditioner weight type stat: %s", wtype_stat_to_str(model_loader.get_conditioner_wtype_stat()).c_str());
LOG_INFO("Diffusion model weight type stat: %s", wtype_stat_to_str(model_loader.get_diffusion_model_wtype_stat()).c_str());
LOG_INFO("VAE weight type stat: %s", wtype_stat_to_str(model_loader.get_vae_wtype_stat()).c_str());

LOG_DEBUG("ggml tensor size = %d bytes", (int)sizeof(ggml_tensor));

Expand Down