Skip to content

Commit

Permalink
do not warn for empty prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
stduhpf committed Nov 25, 2024
1 parent ddb40b5 commit ec5f18f
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -921,9 +921,9 @@ bool ModelLoader::init_from_gguf_file(const std::string& file_path, const std::s
struct ggml_tensor* dummy = ggml_get_tensor(ctx_meta_, name.c_str());
size_t offset = data_offset + gguf_get_tensor_offset(ctx_gguf_, i);

if(i==0 && starts_with(name,prefix)){
LOG_WARN("Tensors have built-in %s prefix.\n", prefix.c_str());
if(prefix == "model.diffusion_model."){
if (!prefix.empty() && i == 0 && starts_with(name, prefix)) {
LOG_WARN("Tensors have built-in \"%s\" prefix.\n", prefix.c_str());
if (prefix == "model.diffusion_model.") {
// the user probably used `--diffusion-model` instead of `-m`
LOG_WARN("Try using `-m`or `--model` instead of `--diffusion-model`\n");
}
Expand Down Expand Up @@ -1009,7 +1009,7 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const

nlohmann::json header_ = nlohmann::json::parse(header_buf.data());

int i =0;
int i = 0;
for (auto& item : header_.items()) {
std::string name = item.key();
nlohmann::json tensor_info = item.value();
Expand Down Expand Up @@ -1060,9 +1060,9 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
n_dims = 1;
}

if(i++==0 && starts_with(name,prefix)){
LOG_WARN("Tensors have built-in %s prefix.\n", prefix.c_str());
if(prefix == "model.diffusion_model."){
if (!prefix.empty() && i++ == 0 && starts_with(name, prefix)) {
LOG_WARN("Tensors have built-in \"%s\" prefix.\n", prefix.c_str());
if (prefix == "model.diffusion_model.") {
// the user probably used `--diffusion-model` instead of `-m`
LOG_WARN("Try using `-m`or `--model` instead of `--diffusion-model`\n");
}
Expand Down Expand Up @@ -1451,9 +1451,9 @@ bool ModelLoader::init_from_ckpt_file(const std::string& file_path, const std::s
{
std::string name = zip_entry_name(zip);
size_t pos = name.find("data.pkl");
if(i==0 && starts_with(name,prefix)){
LOG_WARN("Tensors have built-in %s prefix.\n", prefix.c_str());
if(prefix == "model.diffusion_model."){
if (!prefix.empty() && i == 0 && starts_with(name, prefix)) {
LOG_WARN("Tensors have built-in \"%s\" prefix.\n", prefix.c_str());
if (prefix == "model.diffusion_model.") {
// the user probably used `--diffusion-model` instead of `-m`
LOG_WARN("Try using `-m`or `--model` instead of `--diffusion-model`\n");
}
Expand Down

0 comments on commit ec5f18f

Please sign in to comment.