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

Method forward

codegeex/megatron/model/transformer.py:878–892  ·  view source on GitHub ↗
(self, inputs, **kwargs)

Source from the content-addressed store, hash-verified

876 """
877
878 def forward(self, inputs, **kwargs):
879 assert torch.is_tensor(inputs) or isinstance(inputs, tuple)
880 if torch.is_tensor(inputs) or len(inputs) == 2:
881 # No attention mask forwarded, search for args.attn_mask
882 if not hasattr(self, "_args"):
883 self._args = get_args()
884 hidden_states, query_hidden_state = inputs
885 attention_mask = self._args.attn_mask
886 return super().forward(hidden_states, query_hidden_state, attention_mask, **kwargs)
887 elif len(inputs) == 3:
888 # Attention mask is an activation.
889 hidden_states, query_hidden_state, attention_mask = inputs[0], inputs[1]
890 return super().forward(*inputs, **kwargs), attention_mask
891 else:
892 raise RuntimeError("Received more inputs than understood.")
893
894
895class ParallelTransformer(MegatronModule):

Callers

nothing calls this directly

Calls 2

get_argsFunction · 0.90
forwardMethod · 0.45

Tested by

no test coverage detected