File tree Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Expand file tree Collapse file tree 1 file changed +9
-9
lines changed Original file line number Diff line number Diff line change @@ -1424,6 +1424,14 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
14241424 throw std::runtime_error (format (" missing tensor info mapping for %s" , tn.str ().c_str ()));
14251425 }
14261426
1427+ // skip unused tensors
1428+ if (info.op == GGML_OP_NONE) {
1429+ LLAMA_LOG_WARN (" model has unused tensor %s -- ignoring\n " , tn.str ().c_str ());
1430+ ml.n_created ++;
1431+
1432+ return nullptr ;
1433+ }
1434+
14271435 // tensors with "bias" suffix are always used with GGML_OP_ADD
14281436 ggml_op op;
14291437 bool bias = tn.suffix != nullptr && strcmp (tn.suffix , " bias" ) == 0 ;
@@ -1460,15 +1468,7 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
14601468 GGML_ABORT (" invalid layer %d for tensor %s" , info.layer , tn.str ().c_str ());
14611469 }
14621470
1463- ggml_backend_buffer_type_t buft;
1464-
1465- if (op == GGML_OP_NONE) {
1466- LLAMA_LOG_WARN (" tensor %s has no operation assigned, using host buffer\n " , tn.str ().c_str ());
1467- auto * cpu_dev = ggml_backend_dev_by_type (GGML_BACKEND_DEVICE_TYPE_CPU);
1468- buft = ggml_backend_dev_buffer_type (cpu_dev);
1469- } else {
1470- buft = select_weight_buft (hparams, t_meta, op, *buft_list);
1471- }
1471+ ggml_backend_buffer_type_t buft = select_weight_buft (hparams, t_meta, op, *buft_list);
14721472 if (!buft) {
14731473 throw std::runtime_error (format (" failed to find a compatible buffer type for tensor %s" , tn.str ().c_str ()));
14741474 }
You can’t perform that action at this time.
0 commit comments