Skip to content

Commit 6c7fd67

Browse files
authored
llama : support tie embedding for chatglm models (#13328)
1 parent 141a908 commit 6c7fd67

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/llama-model.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3510,7 +3510,11 @@ bool llama_model::load_tensors(llama_model_loader & ml) {
35103510

35113511
// output
35123512
output_norm = create_tensor(tn(LLM_TENSOR_OUTPUT_NORM, "weight"), {n_embd}, 0);
3513-
output = create_tensor(tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab}, 0);
3513+
output = create_tensor(tn(LLM_TENSOR_OUTPUT, "weight"), {n_embd, n_vocab}, TENSOR_NOT_REQUIRED);
3514+
// if output is NULL, init from the input tok embed
3515+
if (output == NULL) {
3516+
output = create_tensor(tn(LLM_TENSOR_TOKEN_EMBD, "weight"), {n_embd, n_vocab}, TENSOR_DUPLICATED);
3517+
}
35143518

35153519
for (int i = 0; i < n_layer; ++i) {
35163520
auto & layer = layers[i];

0 commit comments

Comments
 (0)