Torch Bicubic Upsample for 5D data

As per the docs, Bicubic upsample is supported for 5D data but it’s giving an error. Also when I opened the functional file, there is no case for 5D and bicubic.
For reproducing, see the code, please. Can someone explain to me that its a kind of PyTorch bug or docs needs explanation? Thanks alot.

import torch
bicubic_upsampling = torch.nn.Upsample(scale_factor=4, mode='bicubic', align_corners=True)
bu = bicubic_upsampling(torch.rand(8,7,3,100,100))
#NotImplementedError: Input Error: Only 3D, 4D and 5D input Tensors supported (got 5D)
#for the modes: nearest | linear | bilinear | bicubic | trilinear (got bicubic)

So in reality, bicubic is only supported for 4d inputs, i.e. spatial data. If anything you would need tricubic for 5d inputs (but that isn’t implemented). What happens is that the error messages for invalid shapes and bicubic haven’t been written, so you get a “stop-all” error message.

The key word in the documentation is respectively.

The algorithms available for upsampling are nearest neighbor and linear, bilinear, bicubic and trilinear for 3D, 4D and 5D input Tensor, respectively.

So this is hard to parse, but let me add paratheses: … are (nearest neighbor) and ((linear), (bilinear, bicubic) and (trilinear) for 3d, 4d, 5d, input Tensor respectively).

You would seem to have a point that both the error message and the documentation could use improvement.

The other part is that I don’t think the function you are asking for has been implemented yet.

Best regards


1 Like