(self, src_tokens)
| 95 | ] |
| 96 | |
| 97 | def encode(self, src_tokens): |
| 98 | # embed = self.token_embed_table(src_tokens) * self.embed_scale # fail in runtime because of lacking broadcasting |
| 99 | embed = self.token_embed_table(src_tokens) |
| 100 | # TODO: add the support for positional embedding |
| 101 | |
| 102 | # BxTxC -> TxBxC |
| 103 | x = embed.transpose(0, 1) |
| 104 | |
| 105 | for layer in self.encoder_layers: |
| 106 | x = layer(x) |
| 107 | |
| 108 | return x |
| 109 | |
| 110 | def get_random_inputs(self, method): |
| 111 | if method == "encode": |
no outgoing calls