MCPcopy Create free account
hub / github.com/PeizeSun/TransTrack / interpolate

Function interpolate

util/misc.py:473–496  ·  view source on GitHub ↗

Equivalent to nn.functional.interpolate, but with support for empty batch sizes. This will eventually be supported natively by PyTorch, and this class can go away.

(input, size=None, scale_factor=None, mode="nearest", align_corners=None)

Source from the content-addressed store, hash-verified

471
472
473def interpolate(input, size=None, scale_factor=None, mode="nearest", align_corners=None):
474 # type: (Tensor, Optional[List[int]], Optional[float], str, Optional[bool]) -> Tensor
475 """
476 Equivalent to nn.functional.interpolate, but with support for empty batch sizes.
477 This will eventually be supported natively by PyTorch, and this
478 class can go away.
479 """
480 if version.parse(torchvision.__version__) < version.Version('0.7'):
481 if input.numel() > 0:
482 return torch.nn.functional.interpolate(
483 input, size, scale_factor, mode, align_corners
484 )
485
486 output_shape = _output_size(2, input, size, scale_factor)
487 output_shape = list(input.shape[:-2]) + list(output_shape)
488 major_version, minor_version = torchvision.__version__.split('.')[:2]
489 if float(major_version) < 1 and float(minor_version) < 5:
490 return _NewEmptyTensorOp.apply(input, output_shape)
491 elif float(major_version) < 1 and float(minor_version) < 7:
492 return _new_empty_tensor(input, output_shape)
493 else:
494 return torch.empty(input, output_shape)
495 else:
496 return torchvision.ops.misc.interpolate(input, size, scale_factor, mode, align_corners)
497
498
499def get_total_grad_norm(parameters, norm_type=2):

Callers 7

resizeFunction · 0.90
loss_masksMethod · 0.90
loss_masksMethod · 0.90
loss_masksMethod · 0.90
forwardMethod · 0.90
loss_masksMethod · 0.90
loss_masksMethod · 0.90

Calls 1

_output_sizeFunction · 0.90

Tested by 2

loss_masksMethod · 0.72
loss_masksMethod · 0.72