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

Method construct

codegeex/mindspore/src/pangu_alpha.py:92–103  ·  view source on GitHub ↗
(
            self, input_ids, input_position, init_reset, batch_valid_length
    )

Source from the content-addressed store, hash-verified

90 self.batch_size = config.batch_size
91
92 def construct(
93 self, input_ids, input_position, init_reset, batch_valid_length
94 ):
95 word_embedding, word_table = self.word_embedding(input_ids)
96 if self.use_past and not self.is_first_iteration:
97 _, seq_length = F.shape(input_ids)
98 # self.print("==batch_valid_length is: ", batch_valid_length, ", transform into: ", self.batch_size, "*", seq_length)
99 input_position = batch_valid_length.view(self.batch_size, seq_length)
100 position_embedding, _ = self.position_embedding(input_position)
101 embed = self.add(word_embedding, position_embedding)
102 embed = self.dropout(embed)
103 return embed, word_table
104
105 def get_word_embedding_weight(self):
106 return self.word_embedding.embedding_table

Callers

nothing calls this directly

Calls 1

addMethod · 0.45

Tested by

no test coverage detected