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

Function interpolation

pointops2/functions/pointops_ablation.py:165–179  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected