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

Method forward

pointops2/functions/pointops_ablation.py:184–200  ·  view source on GitHub ↗

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

(ctx, xyz, new_xyz, input, offset, new_offset, k=3)

Source from the content-addressed store, hash-verified

182class Interpolation(Function):
183 @staticmethod
184 def forward(ctx, xyz, new_xyz, input, offset, new_offset, k=3):
185 """
186 input: xyz: (m, 3), new_xyz: (n, 3), input: (m, c), offset: (b), new_offset: (b)
187 output: (n, c)
188 """
189 assert xyz.is_contiguous() and new_xyz.is_contiguous() and input.is_contiguous()
190 idx, dist = knnquery(k, xyz, new_xyz, offset, new_offset) # (n, k), (n, k)
191 dist_recip = 1.0 / (dist + 1e-8) # (n, k)
192 norm = torch.sum(dist_recip, dim=1, keepdim=True)
193 weight = dist_recip / norm # (n, k)
194
195 n, c, m = new_xyz.shape[0], input.shape[1], input.shape[0]
196 output = torch.cuda.FloatTensor(n, c).zero_()
197 pointops_cuda.interpolation_forward_cuda(n, c, k, input, idx, weight, output)
198 ctx.m, ctx.k = m, k
199 ctx.save_for_backward(idx, weight)
200 return output
201
202 @staticmethod
203 def backward(ctx, grad_output):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected