MCPcopy
hub / github.com/pytorch/vision / test_fasterrcnn_switch_devices

Function test_fasterrcnn_switch_devices

test/test_models.py:592–624  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

590
591@needs_cuda
592def 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
627def test_generalizedrcnn_transform_repr():

Callers

nothing calls this directly

Calls 2

checkOutFunction · 0.85
_check_input_backpropFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…