File size: 426 Bytes
491eded |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
from torch.autograd import Function
import torch
import torch.nn.functional as F
__all__ = ['trilinear_devoxelize']
def trilinear_devoxelize(c, coords, r, training=None):
coords = (coords * 2 + 1.0) / r - 1.0
coords = coords.permute(0, 2, 1).reshape(c.shape[0], 1, 1, -1, 3)
f = F.grid_sample(input=c, grid=coords, padding_mode='border', align_corners=False)
f = f.squeeze(dim=2).squeeze(dim=2)
return f
|