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

Method construct

codegeex/mindspore/src/pangu_alpha.py:527–544  ·  view source on GitHub ↗

r"""Forward process of the pangu alpha model

(self, input_ids, input_position=None, attention_mask=None)

Source from the content-addressed store, hash-verified

525 self.micro_batch_step = config.parallel_config.micro_batch_num
526
527 def construct(self, input_ids, input_position=None, attention_mask=None):
528 r"""Forward process of the pangu alpha model"""
529 tokens = self.slice(input_ids, (0, 0), (self.batch_size, -1), (1, 1))
530 # P.Print()("==net tokens is:", tokens)
531 input_position = self.slice(input_position, (0, 0), (self.batch_size, self.len), (1, 1))
532 decoder_attention_masks = self.slice2(attention_mask, (0, 0, 0), (self.batch_size, self.len, self.len),
533 (1, 1, 1))
534 input_mask = F.cast(self.not_equal(tokens, self.eod_token), mstype.float32)
535 logits = self.network(tokens, input_position, decoder_attention_masks)
536 # P.Print()("==logits_is:", logits, ",shape is:", logits.shape)
537 # Get label corresponding to input tokens
538 labels = self.slice(input_ids, (0, 1), (self.batch_size, self.len + 1), (1, 1))
539 labels = P.Reshape()(labels, (-1,))
540 input_mask = P.Reshape()(input_mask, (-1,))
541 # P.Print()("==input_mask is:", input_mask)
542 output = self.loss(logits, labels, input_mask)
543 # P.Print()("==net output is:", output)
544 return output
545
546
547class EvalNet(nn.Cell):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected