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)
| 448 | |
| 449 | |
| 450 | def interpolate(input, size=None, scale_factor=None, mode="nearest", align_corners=None): |
| 451 | # type: (Tensor, Optional[List[int]], Optional[float], str, Optional[bool]) -> Tensor |
| 452 | """ |
| 453 | Equivalent to nn.functional.interpolate, but with support for empty batch sizes. |
| 454 | This will eventually be supported natively by PyTorch, and this |
| 455 | class can go away. |
| 456 | """ |
| 457 | if float(torchvision.__version__.split(".")[1]) < 7.0: |
| 458 | if input.numel() > 0: |
| 459 | return torch.nn.functional.interpolate( |
| 460 | input, size, scale_factor, mode, align_corners |
| 461 | ) |
| 462 | |
| 463 | output_shape = _output_size(2, input, size, scale_factor) |
| 464 | output_shape = list(input.shape[:-2]) + list(output_shape) |
| 465 | return _new_empty_tensor(input, output_shape) |
| 466 | else: |
| 467 | return torchvision.ops.misc.interpolate(input, size, scale_factor, mode, align_corners) |
no outgoing calls
no test coverage detected