@@ -921,9 +921,9 @@ bool ModelLoader::init_from_gguf_file(const std::string& file_path, const std::s
921921 struct ggml_tensor * dummy = ggml_get_tensor (ctx_meta_, name.c_str ());
922922 size_t offset = data_offset + gguf_get_tensor_offset (ctx_gguf_, i);
923923
924- if (i== 0 && starts_with (name,prefix)){
925- LOG_WARN (" Tensors have built-in %s prefix.\n " , prefix.c_str ());
926- if (prefix == " model.diffusion_model." ){
924+ if (!prefix. empty () && i == 0 && starts_with (name, prefix)) {
925+ LOG_WARN (" Tensors have built-in \" %s \" prefix.\n " , prefix.c_str ());
926+ if (prefix == " model.diffusion_model." ) {
927927 // the user probably used `--diffusion-model` instead of `-m`
928928 LOG_WARN (" Try using `-m`or `--model` instead of `--diffusion-model`\n " );
929929 }
@@ -1009,7 +1009,7 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
10091009
10101010 nlohmann::json header_ = nlohmann::json::parse (header_buf.data ());
10111011
1012- int i =0 ;
1012+ int i = 0 ;
10131013 for (auto & item : header_.items ()) {
10141014 std::string name = item.key ();
10151015 nlohmann::json tensor_info = item.value ();
@@ -1060,9 +1060,9 @@ bool ModelLoader::init_from_safetensors_file(const std::string& file_path, const
10601060 n_dims = 1 ;
10611061 }
10621062
1063- if ( i++== 0 && starts_with (name,prefix)){
1064- LOG_WARN (" Tensors have built-in %s prefix.\n " , prefix.c_str ());
1065- if (prefix == " model.diffusion_model." ){
1063+ if (!prefix. empty () && i++ == 0 && starts_with (name, prefix)) {
1064+ LOG_WARN (" Tensors have built-in \" %s \" prefix.\n " , prefix.c_str ());
1065+ if (prefix == " model.diffusion_model." ) {
10661066 // the user probably used `--diffusion-model` instead of `-m`
10671067 LOG_WARN (" Try using `-m`or `--model` instead of `--diffusion-model`\n " );
10681068 }
@@ -1451,9 +1451,9 @@ bool ModelLoader::init_from_ckpt_file(const std::string& file_path, const std::s
14511451 {
14521452 std::string name = zip_entry_name (zip);
14531453 size_t pos = name.find (" data.pkl" );
1454- if (i== 0 && starts_with (name,prefix)){
1455- LOG_WARN (" Tensors have built-in %s prefix.\n " , prefix.c_str ());
1456- if (prefix == " model.diffusion_model." ){
1454+ if (!prefix. empty () && i == 0 && starts_with (name, prefix)) {
1455+ LOG_WARN (" Tensors have built-in \" %s \" prefix.\n " , prefix.c_str ());
1456+ if (prefix == " model.diffusion_model." ) {
14571457 // the user probably used `--diffusion-model` instead of `-m`
14581458 LOG_WARN (" Try using `-m`or `--model` instead of `--diffusion-model`\n " );
14591459 }
0 commit comments