MCPcopy Create free account
hub / github.com/modelscope/modelscope / tie_weights

Function tie_weights

modelscope/utils/checkpoint.py:541–546  ·  view source on GitHub ↗
(model, tie_word_embeddings=False)

Source from the content-addressed store, hash-verified

539 output_embeddings.out_features = input_embeddings.num_embeddings
540
541 def tie_weights(model, tie_word_embeddings=False):
542 if tie_word_embeddings:
543 output_embeddings = model.head.get_output_embeddings()
544 if output_embeddings is not None:
545 input_embeddings = model.encoder.get_input_embeddings()
546 _tie_or_clone_weights(output_embeddings, input_embeddings)
547
548 # TODO Sharded ckpt
549 ckpt_file = os.path.join(model_local_dir, ModelFile.TORCH_MODEL_BIN_FILE)

Callers 1

Calls 3

_tie_or_clone_weightsFunction · 0.85
get_output_embeddingsMethod · 0.45
get_input_embeddingsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…