MCPcopy Create free account
hub / github.com/NVIDIA/MinkowskiEngine / test

Method test

tests/python/interpolation.py:42–85  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

40
41class TestInterpolation(unittest.TestCase):
42 def test(self):
43 in_channels, D = 2, 2
44 coords, feats, labels = data_loader(in_channels, batch_size=2)
45 feats = feats.double()
46 tfield = torch.Tensor(
47 [
48 [0, 0.1, 2.7],
49 [0, 0.3, 2],
50 [1, 1.5, 2.5],
51 ]
52 ).double()
53 feats.requires_grad_()
54 input = SparseTensor(feats, coordinates=coords)
55 interp = MinkowskiInterpolation(return_kernel_map=True, return_weights=False)
56 output, (in_map, out_map) = interp(input, tfield)
57 print(input)
58 print(output)
59
60 # Check backward
61 output.sum().backward()
62 fn = MinkowskiInterpolationFunction()
63 self.assertTrue(
64 gradcheck(
65 fn,
66 (
67 input.F,
68 tfield,
69 input.coordinate_map_key,
70 input._manager,
71 ),
72 )
73 )
74
75 for i in range(LEAK_TEST_ITER):
76 input = SparseTensor(feats, coordinates=coords)
77 tfield = torch.DoubleTensor(
78 [
79 [0, 0.1, 2.7],
80 [0, 0.3, 2],
81 [1, 1.5, 2.5],
82 ],
83 )
84 output, _ = interp(input, tfield)
85 output.sum().backward()
86
87 def test_gpu(self):
88 in_channels, D = 2, 2

Callers

nothing calls this directly

Calls 8

data_loaderFunction · 0.90
SparseTensorClass · 0.90
gradcheckFunction · 0.90
doubleMethod · 0.80
requires_grad_Method · 0.80
backwardMethod · 0.45

Tested by

no test coverage detected