Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add torch jit ignore decorator to Lightning properties #3295

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pytorch_lightning/core/lightning.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def __init__(self, *args, **kwargs):
self._example_input_array = None
self._datamodule = None

@torch.jit.ignore
@property
def example_input_array(self) -> Any:
return self._example_input_array
Expand All @@ -84,6 +85,7 @@ def example_input_array(self) -> Any:
def example_input_array(self, example: Any) -> None:
self._example_input_array = example

@torch.jit.ignore
@property
def datamodule(self) -> Any:
return self._datamodule
Expand All @@ -92,6 +94,7 @@ def datamodule(self) -> Any:
def datamodule(self, datamodule: Any) -> None:
self._datamodule = datamodule

@torch.jit.ignore
@property
def on_gpu(self):
"""
Expand Down Expand Up @@ -1720,6 +1723,7 @@ def to_onnx(self, file_path: str, input_sample: Optional[Tensor] = None, **kwarg

torch.onnx.export(self, input_data, file_path, **kwargs)

@torch.jit.ignore
@property
def hparams(self) -> Union[AttributeDict, str]:
if not hasattr(self, '_hparams'):
Expand Down
2 changes: 2 additions & 0 deletions pytorch_lightning/utilities/device_dtype_mixin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ def __init__(self):
self._dtype = torch.get_default_dtype()
self._device = torch.device('cpu')

@torch.jit.ignore
@property
def dtype(self) -> Union[str, torch.dtype]:
return self._dtype
Expand All @@ -20,6 +21,7 @@ def dtype(self, new_dtype: Union[str, torch.dtype]):
# necessary to avoid infinite recursion
raise RuntimeError('Cannot set the dtype explicitly. Please use module.to(new_dtype).')

@torch.jit.ignore
@property
def device(self) -> Union[str, torch.device]:
return self._device
Expand Down