Save and load a TorchScript model
(m)
| 160 | """Check that a nn.Module's results in TorchScript match eager and that it can be exported""" |
| 161 | |
| 162 | def get_export_import_copy(m): |
| 163 | """Save and load a TorchScript model""" |
| 164 | with TemporaryDirectory() as dir: |
| 165 | path = os.path.join(dir, "script.pt") |
| 166 | m.save(path) |
| 167 | imported = torch.jit.load(path) |
| 168 | return imported |
| 169 | |
| 170 | sm = torch.jit.script(nn_module) |
| 171 | sm.eval() |
no test coverage detected
searching dependent graphs…