Skip to content

Commit

Permalink
TRT --half fix autocast images to FP16 (#8435)
Browse files Browse the repository at this point in the history
* TRT `--half` fix autocast images to FP16

Resolves bug raised in #7822

* Update common.py
  • Loading branch information
glenn-jocher committed Jul 1, 2022
1 parent 8983324 commit d94b470
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions models/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,9 @@ def wrap_frozen_graph(gd, inputs, outputs):
def forward(self, im, augment=False, visualize=False, val=False):
# YOLOv5 MultiBackend inference
b, ch, h, w = im.shape # batch, channel, height, width
if self.fp16 and im.dtype != torch.float16:
im = im.half() # to FP16

if self.pt: # PyTorch
y = self.model(im, augment=augment, visualize=visualize)[0]
elif self.jit: # TorchScript
Expand Down

0 comments on commit d94b470

Please sign in to comment.