A TorchScript-compatible version of forward. Encoders which use additional arguments may want to override this method for TorchScript compatibility.
(self, net_input: Dict[str, Tensor])
| 41 | raise NotImplementedError |
| 42 | |
| 43 | def forward_torchscript(self, net_input: Dict[str, Tensor]): |
| 44 | """A TorchScript-compatible version of forward. |
| 45 | |
| 46 | Encoders which use additional arguments may want to override |
| 47 | this method for TorchScript compatibility. |
| 48 | """ |
| 49 | if torch.jit.is_scripting(): |
| 50 | return self.forward( |
| 51 | src_tokens=net_input["src_tokens"], |
| 52 | src_lengths=net_input["src_lengths"], |
| 53 | ) |
| 54 | else: |
| 55 | return self.forward_non_torchscript(net_input) |
| 56 | |
| 57 | @torch.jit.unused |
| 58 | def forward_non_torchscript(self, net_input: Dict[str, Tensor]): |
no test coverage detected