Compile torch model with torch>=2.0 Args: kwargs: backend: The backend param of torch.compile mode: The mode param of torch.compile
(self, **kwargs)
| 133 | save_config_function(target_folder, config) |
| 134 | |
| 135 | def compile(self, **kwargs): |
| 136 | """Compile torch model with torch>=2.0 |
| 137 | |
| 138 | Args: |
| 139 | kwargs: |
| 140 | backend: The backend param of torch.compile |
| 141 | mode: The mode param of torch.compile |
| 142 | """ |
| 143 | if version.parse(torch.__version__) >= version.parse('2.0.0.dev'): |
| 144 | return torch.compile(self, **kwargs) |
| 145 | else: |
| 146 | logger.warning( |
| 147 | f'Torch compiling needs torch version >= 2.0.0, your torch version is : {torch.__version__},' |
| 148 | f' returns original model') |
| 149 | return self |
no outgoing calls