()
| 590 | |
| 591 | @needs_cuda |
| 592 | def test_fasterrcnn_switch_devices(): |
| 593 | def checkOut(out): |
| 594 | assert len(out) == 1 |
| 595 | assert "boxes" in out[0] |
| 596 | assert "scores" in out[0] |
| 597 | assert "labels" in out[0] |
| 598 | |
| 599 | model = models.detection.fasterrcnn_resnet50_fpn(num_classes=50, weights=None, weights_backbone=None) |
| 600 | model.cuda() |
| 601 | model.eval() |
| 602 | input_shape = (3, 300, 300) |
| 603 | x = torch.rand(input_shape, device="cuda") |
| 604 | model_input = [x] |
| 605 | out = model(model_input) |
| 606 | assert model_input[0] is x |
| 607 | |
| 608 | checkOut(out) |
| 609 | |
| 610 | with torch.cuda.amp.autocast(): |
| 611 | out = model(model_input) |
| 612 | |
| 613 | checkOut(out) |
| 614 | |
| 615 | _check_input_backprop(model, model_input) |
| 616 | |
| 617 | # now switch to cpu and make sure it works |
| 618 | model.cpu() |
| 619 | x = x.cpu() |
| 620 | out_cpu = model([x]) |
| 621 | |
| 622 | checkOut(out_cpu) |
| 623 | |
| 624 | _check_input_backprop(model, [x]) |
| 625 | |
| 626 | |
| 627 | def test_generalizedrcnn_transform_repr(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…