Skip to content

Commit 51f311e

Browse files
authored
llama : skip loading unused tensors (#12004)
* llama : assign unknown/unused tensors to host buffer type ggml-ci * llama : skip unused tensors ggml-ci
1 parent 586d5fe commit 51f311e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/llama-model.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)