MCPcopy Create free account
hub / github.com/FLC777/GLAT / forward_torchscript

Method forward_torchscript

fairseq/models/fairseq_encoder.py:43–55  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

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]):

Callers 1

forward_encoderMethod · 0.80

Calls 2

forwardMethod · 0.95

Tested by

no test coverage detected