MCPcopy Create free account
hub / github.com/zai-org/CodeGeeX / set_state_dict

Method set_state_dict

codegeex/paddle/codegeex_model.py:911–944  ·  view source on GitHub ↗

Customized load.

(self, state_dict, use_structured_name=True)

Source from the content-addressed store, hash-verified

909 return state_dict_
910
911 def set_state_dict(self, state_dict, use_structured_name=True):
912 """Customized load."""
913
914 # Embedding.
915 if self._embedding_key in state_dict:
916 state_dict_ = state_dict[self._embedding_key]
917 else:
918 # for backward compatibility.
919 state_dict_ = {}
920 for key in state_dict.keys():
921 if '_embeddings' in key:
922 state_dict_[key] = state_dict[key]
923 self.embedding.set_state_dict(state_dict_, use_structured_name=use_structured_name)
924
925 if self._topQueryEmbedding_key in state_dict:
926 state_dict_ = state_dict[self._topQueryEmbedding_key]
927 else:
928 # for backward compatibility.
929 state_dict_ = {}
930 for key in state_dict.keys():
931 if '_embeddings' in key:
932 state_dict_[key] = state_dict[key]
933 self.topQueryEmbedding.set_state_dict(state_dict_, use_structured_name=use_structured_name)
934
935 # Transformer.
936 if self._transformer_key in state_dict:
937 state_dict_ = state_dict[self._transformer_key]
938 else:
939 # for backward compatibility.
940 state_dict_ = {}
941 for key in state_dict.keys():
942 if 'transformer.' in key:
943 state_dict_[key.split('transformer.')[1]] = state_dict[key]
944 self.transformer.set_state_dict(state_dict_, use_structured_name=use_structured_name)
945
946
947class CodeGeeXModel(paddle.nn.Layer):

Callers

nothing calls this directly

Calls 1

set_state_dictMethod · 0.45

Tested by

no test coverage detected