MCPcopy Create free account
hub / github.com/QWTforGithub/T2LDM / forward

Method forward

eval/modules/emd/emd_module.py:48–76  ·  view source on GitHub ↗
(ctx, xyz1, xyz2, eps, iters)

Source from the content-addressed store, hash-verified

46class emdFunction(Function):
47 @staticmethod
48 def forward(ctx, xyz1, xyz2, eps, iters):
49 batchsize, n, _ = xyz1.size()
50 _, m, _ = xyz2.size()
51
52 assert (n == m)
53 assert (xyz1.size()[0] == xyz2.size()[0])
54 # assert(n % 1024 == 0)
55 assert (batchsize <= 512)
56
57 xyz1 = xyz1.contiguous().float().cuda()
58 xyz2 = xyz2.contiguous().float().cuda()
59 dist = torch.zeros(batchsize, n, device='cuda').contiguous()
60 assignment = torch.zeros(batchsize, n, device='cuda', dtype=torch.int32).contiguous() - 1
61 assignment_inv = torch.zeros(batchsize, m, device='cuda', dtype=torch.int32).contiguous() - 1
62 price = torch.zeros(batchsize, m, device='cuda').contiguous()
63 bid = torch.zeros(batchsize, n, device='cuda', dtype=torch.int32).contiguous()
64 bid_increments = torch.zeros(batchsize, n, device='cuda').contiguous()
65 max_increments = torch.zeros(batchsize, m, device='cuda').contiguous()
66 unass_idx = torch.zeros(batchsize * n, device='cuda', dtype=torch.int32).contiguous()
67 max_idx = torch.zeros(batchsize * m, device='cuda', dtype=torch.int32).contiguous()
68 unass_cnt = torch.zeros(512, dtype=torch.int32, device='cuda').contiguous()
69 unass_cnt_sum = torch.zeros(512, dtype=torch.int32, device='cuda').contiguous()
70 cnt_tmp = torch.zeros(512, dtype=torch.int32, device='cuda').contiguous()
71
72 emd.forward(xyz1, xyz2, dist, assignment, price, assignment_inv, bid, bid_increments, max_increments, unass_idx,
73 unass_cnt, unass_cnt_sum, cnt_tmp, max_idx, eps, iters)
74
75 ctx.save_for_backward(xyz1, xyz2, assignment)
76 return dist, assignment
77
78 @staticmethod
79 def backward(ctx, graddist, gradidx):

Callers

nothing calls this directly

Calls 1

forwardMethod · 0.45

Tested by

no test coverage detected