Tensor initialization on device improvements (#6959)

* Update common.py speed improvements

Eliminate .to() ops where possible for reduced data transfer overhead. Primarily affects warmup and PyTorch Hub inference.

* Updates

* Updates

* Update detect.py

* Update val.py
This commit is contained in:
Glenn Jocher authored and GitHub committed 2022-03-12 14:00:48 +01:00
1 parent 52c1399fdc
commit 701e1177ac
2 files changed
+4 -4

No files matched your search

+1 -1
View File
@@ -466,7 +466,7 @@ class DetectMultiBackend(nn.Module):
# Warmup model by running inference once
if self.pt or self.jit or self.onnx or self.engine: # warmup types
if isinstance(self.device, torch.device) and self.device.type != 'cpu': # only warmup GPU models
im = torch.zeros(*imgsz).to(self.device).type(torch.half if self.fp16 else torch.float) # input image
im = torch.zeros(*imgsz, dtype=torch.half if self.fp16 else torch.float, device=self.device) # input
self.forward(im) # warmup
@staticmethod