core.typed_torch#
Utilities for improved type hinting with torch interfaces.
Module Contents#
Classes#
Protocol allowing us to unwrap |
Functions#
Returns the provided module unchanged, but with correct type hints. |
Data#
API#
- core.typed_torch.P#
‘ParamSpec(…)’
- core.typed_torch.R_co#
‘TypeVar(…)’
- class core.typed_torch._Module#
Bases:
typing.Generic[core.typed_torch.P,core.typed_torch.R_co],typing.ProtocolProtocol allowing us to unwrap
forward.- forward(
- *args: core.typed_torch.P,
- **kwargs: core.typed_torch.P,
Forward method of the matching torch.nn.Module.
- core.typed_torch.apply_module(
- m: core.typed_torch._Module[core.typed_torch.P, core.typed_torch.R_co],
- *,
- check_subclass: bool = True,
Returns the provided module unchanged, but with correct type hints.
- Parameters:
m – An instance of a subclass of
torch.nn.Module.check_subclass – If
True, checks thatmis a subclass oftorch.nn.Moduleand raises aTypeErrorif not.
- Returns:
That module unchanged, but with correct type hints.