Run a single forward pass with each model
(model_name, batch_size)
| 429 | 'model_name', list_models(exclude_filters=EXCLUDE_FILTERS + EXCLUDE_JIT_FILTERS, name_matches_cfg=True)) |
| 430 | @pytest.mark.parametrize('batch_size', [1]) |
| 431 | def test_model_forward_torchscript(model_name, batch_size): |
| 432 | """Run a single forward pass with each model""" |
| 433 | input_size = _get_input_size(model_name=model_name, target=TARGET_JIT_SIZE) |
| 434 | if max(input_size) > MAX_JIT_SIZE: |
| 435 | pytest.skip("Fixed input size model > limit.") |
| 436 | |
| 437 | with set_scriptable(True): |
| 438 | model = create_model(model_name, pretrained=False) |
| 439 | model.eval() |
| 440 | |
| 441 | model = torch.jit.script(model) |
| 442 | model.to(torch_device) |
| 443 | outputs = model(torch.randn((batch_size, *input_size))) |
| 444 | |
| 445 | assert outputs.shape[0] == batch_size |
| 446 | assert not torch.isnan(outputs).any(), 'Output included NaNs' |
| 447 | |
| 448 | |
| 449 | EXCLUDE_FEAT_FILTERS = [ |
nothing calls this directly
no test coverage detected