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

Class Subtraction

pointops2/functions/pointops.py:695–720  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

693 return p_idx
694
695class Subtraction(Function):
696 @staticmethod
697 def forward(ctx, input1, input2, idx):
698 """
699 input: input1: (n, c), input2: (n, c), idx: (n, nsample)
700 output: (n, nsample, c)
701 """
702 assert input1.is_contiguous() and input2.is_contiguous()
703 n, c = input1.shape; nsample = idx.shape[-1]
704 output = torch.cuda.FloatTensor(n, nsample, c).zero_()
705 pointops_cuda.subtraction_forward_cuda(n, nsample, c, input1, input2, idx, output)
706 ctx.save_for_backward(idx)
707 return output
708
709 @staticmethod
710 def backward(ctx, grad_output):
711 """
712 input: grad_out: (n, nsample, c)
713 output: grad_input1: (n, c), grad_input2: (n, c)
714 """
715 idx, = ctx.saved_tensors
716 n, nsample, c = grad_output.shape
717 grad_input1 = torch.cuda.FloatTensor(n, c).zero_()
718 grad_input2 = torch.cuda.FloatTensor(n, c).zero_()
719 pointops_cuda.subtraction_backward_cuda(n, nsample, c, idx, grad_output, grad_input1, grad_input2)
720 return grad_input1, grad_input2, None
721
722subtraction = Subtraction.apply
723

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected