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

Method test_kernelmap_gpu

tests/python/kernel_map.py:34–78  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

32
33class TestKernelMap(unittest.TestCase):
34 def test_kernelmap_gpu(self):
35 print(f"{self.__class__.__name__}: test_kernelmap_gpu")
36 if not torch.cuda.is_available():
37 return
38
39 in_channels, out_channels, D = 2, 3, 2
40 coords, feats, labels = data_loader(in_channels)
41 feats = feats.double()
42 feats.requires_grad_()
43 input = SparseTensor(
44 feats,
45 coordinates=coords,
46 minkowski_algorithm=MinkowskiAlgorithm.SPEED_OPTIMIZED,
47 device="cuda",
48 )
49
50 # Initialize context
51 conv = (
52 MinkowskiConvolution(
53 in_channels,
54 out_channels,
55 kernel_size=3,
56 stride=2,
57 bias=True,
58 dimension=D,
59 )
60 .double()
61 .cuda()
62 )
63 output = conv(input)
64
65 iC = input.C.cpu().numpy()
66 oC = output.C.cpu().numpy()
67 print(iC)
68 print(oC)
69 kernel_maps = output.coordinate_manager.kernel_map(
70 1,
71 2,
72 stride=2,
73 kernel_size=3,
74 )
75 for kernel_index, in_out_map in kernel_maps.items():
76 for i, o in zip(in_out_map[0], in_out_map[1]):
77 print(kernel_index, iC[i], "->", oC[o])
78 self.assertTrue(sum(len(in_map[0]) for k, in_map in kernel_maps.items()) == 16)
79
80 def test_kernelmap(self):
81 print(f"{self.__class__.__name__}: test_kernelmap")

Callers

nothing calls this directly

Calls 7

data_loaderFunction · 0.90
SparseTensorClass · 0.90
convFunction · 0.85
doubleMethod · 0.80
requires_grad_Method · 0.80
kernel_mapMethod · 0.45

Tested by

no test coverage detected