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

Method forward

pointops2/functions/pointops2.py:183–199  ·  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

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected