def forward(ctx, xyz1, xyz2, eps, iters): batchsize, n, _ = xyz1.size() _, m, _ = xyz2.size() assert(n == m) assert(xyz1.size()[0] == xyz2.size()[0]) assert(n % 1024 == 0) assert(batchsize <= 512) xyz1 = xyz1.contiguous().float().cuda() xyz2 = xyz2.contiguous().float().cuda() dist = torch.zeros(batchsize, n, device='cuda').contiguous() assignment = torch.zeros(batchsize, n, device='cuda', dtype=torch.int32).contiguous() - 1 assignment_inv = torch.zeros(batchsize, m, device='cuda', dtype=torch.int32).contiguous() - 1 price = torch.zeros(batchsize, m, device='cuda').contiguous() bid = torch.zeros(batchsize, n, device='cuda', dtype=torch.int32).contiguous() bid_increments = torch.zeros(batchsize, n, device='cuda').contiguous() max_increments = torch.zeros(batchsize, m, device='cuda').contiguous() unass_idx = torch.zeros(batchsize * n, device='cuda', dtype=torch.int32).contiguous() max_idx = torch.zeros(batchsize * m, device='cuda', dtype=torch.int32).contiguous() unass_cnt = torch.zeros(512, dtype=torch.int32, device='cuda').contiguous() unass_cnt_sum = torch.zeros(512, dtype=torch.int32, device='cuda').contiguous() cnt_tmp = torch.zeros(512, dtype=torch.int32, device='cuda').contiguous() emd.forward(xyz1, xyz2, dist, assignment, price, assignment_inv, bid, bid_increments, max_increments, unass_idx, unass_cnt, unass_cnt_sum, cnt_tmp, max_idx, eps, iters) ctx.save_for_backward(xyz1, xyz2, assignment) return dist, assignment
def forward(ctx, xyz1, xyz2): batchsize, n, _ = xyz1.size() _, m, _ = xyz2.size() match = torch.zeros(batchsize, n, m).cuda() cost = torch.zeros(batchsize, ).cuda() temp = torch.zeros(batchsize, 2 * (m + n)).cuda() emd.forward(xyz1, xyz2, match, cost, temp) ctx.save_for_backward(xyz1, xyz2, match) return cost