(self)
| 40 | |
| 41 | class 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 |
nothing calls this directly
no test coverage detected