@@ -826,9 +826,9 @@ bool ModelLoader::init_from_gguf_file(const std::string& file_path, const std::s
826826 struct ggml_tensor * dummy = ggml_get_tensor (ctx_meta_, name.c_str ());
827827 size_t offset = data_offset + gguf_get_tensor_offset (ctx_gguf_, i);
828828
829- if (i== 0 && starts_with (name,prefix)){
830- LOG_WARN (" Tensors have built-in %s prefix.\n " , prefix.c_str ());
831- if (prefix == " model.diffusion_model." ){
829+ if (!prefix. empty () && i == 0 && starts_with (name, prefix)) {
830+ LOG_WARN (" Tensors have built-in \" %s \" prefix.\n " , prefix.c_str ());
831+ if (prefix == " model.diffusion_model." ) {
832832 // the user probably used `--diffusion-model` instead of `-m`
833833 LOG_WARN (" Try using `-m`or `--model` instead of `--diffusion-model`\n " );
834834 }
@@ -912,7 +912,7 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
912912
913913 nlohmann::json header_ = nlohmann::json::parse (header_buf.data ());
914914
915- int i =0 ;
915+ int i = 0 ;
916916 for (auto & item : header_.items ()) {
917917 std::string name = item.key ();
918918 nlohmann::json tensor_info = item.value ();
@@ -963,9 +963,9 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
963963 n_dims = 1 ;
964964 }
965965
966- if ( i++== 0 && starts_with (name,prefix)){
967- LOG_WARN (" Tensors have built-in %s prefix.\n " , prefix.c_str ());
968- if (prefix == " model.diffusion_model." ){
966+ if (!prefix. empty () && i++ == 0 && starts_with (name, prefix)) {
967+ LOG_WARN (" Tensors have built-in \" %s \" prefix.\n " , prefix.c_str ());
968+ if (prefix == " model.diffusion_model." ) {
969969 // the user probably used `--diffusion-model` instead of `-m`
970970 LOG_WARN (" Try using `-m`or `--model` instead of `--diffusion-model`\n " );
971971 }
@@ -1350,9 +1350,9 @@ bool ModelLoader::init_from_ckpt_file(const std::string& file_path, const std::s
13501350 {
13511351 std::string name = zip_entry_name (zip);
13521352 size_t pos = name.find (" data.pkl" );
1353- if (i== 0 && starts_with (name,prefix)){
1354- LOG_WARN (" Tensors have built-in %s prefix.\n " , prefix.c_str ());
1355- if (prefix == " model.diffusion_model." ){
1353+ if (!prefix. empty () && i == 0 && starts_with (name, prefix)) {
1354+ LOG_WARN (" Tensors have built-in \" %s \" prefix.\n " , prefix.c_str ());
1355+ if (prefix == " model.diffusion_model." ) {
13561356 // the user probably used `--diffusion-model` instead of `-m`
13571357 LOG_WARN (" Try using `-m`or `--model` instead of `--diffusion-model`\n " );
13581358 }
0 commit comments