MCPcopy Create free account
hub / github.com/OpenImagingLab/4DSloMo / interpolation

Function interpolation

pointops2/functions/pointops2.py:164–178  ·  view source on GitHub ↗

input: xyz: (m, 3), new_xyz: (n, 3), feat: (m, c), offset: (b), new_offset: (b) output: (n, c)

(xyz, new_xyz, feat, offset, new_offset, k=3)

Source from the content-addressed store, hash-verified

162
163
164def interpolation(xyz, new_xyz, feat, offset, new_offset, k=3):
165 """
166 input: xyz: (m, 3), new_xyz: (n, 3), feat: (m, c), offset: (b), new_offset: (b)
167 output: (n, c)
168 """
169 assert xyz.is_contiguous() and new_xyz.is_contiguous() and feat.is_contiguous()
170 idx, dist = knnquery(k, xyz, new_xyz, offset, new_offset) # (n, 3), (n, 3)
171 dist_recip = 1.0 / (dist + 1e-8) # (n, 3)
172 norm = torch.sum(dist_recip, dim=1, keepdim=True)
173 weight = dist_recip / norm # (n, 3)
174
175 new_feat = torch.cuda.FloatTensor(new_xyz.shape[0], feat.shape[1]).zero_()
176 for i in range(k):
177 new_feat += feat[idx[:, i].long(), :] * weight[:, i].unsqueeze(-1)
178 return new_feat
179
180
181class Interpolation(Function):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected