| 559 | """ |
| 560 | |
| 561 | def __init__(self, backbone, generate=False, pad_token=6, seq_length=2048): |
| 562 | super(EvalNet, self).__init__(auto_prefix=False) |
| 563 | self.backbone = backbone |
| 564 | self.pad_token = pad_token |
| 565 | self.argmax = P.Argmax() |
| 566 | self.generate = generate |
| 567 | self.topk = P.TopK(sorted=True).shard(((1, 1),)) |
| 568 | self.gather = P.Gather().shard(((1, 1), (1,))) |
| 569 | self.log_softmax = P.LogSoftmax().shard(((1, 1, 1),)) |
| 570 | self.get_attention_mask = AttentionMask(seq_length) |
| 571 | self.expand = P.ExpandDims().shard(((1, 1, 1),)) |
| 572 | self.all_ones_attention_mask = Tensor(np.ones((1, 1, seq_length)), mstype.float32) |
| 573 | self.not_equal = P.NotEqual().shard(((1, 1), ())) |
| 574 | |
| 575 | def construct(self, input_ids, current_index, init_reset=True, batch_valid_length=None): |
| 576 | """evaluation net""" |