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

Method test_gpu

tests/python/convolution.py:122–168  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

120 print(output)
121
122 def test_gpu(self):
123 print(f"{self.__class__.__name__}: test_gpu")
124 if not torch.cuda.is_available():
125 return
126 in_channels, out_channels, D = 2, 3, 2
127 coords, feats, labels = data_loader(in_channels)
128 feats = feats.double()
129 feats.requires_grad_()
130
131 # Initialize context
132 conv = MinkowskiConvolution(
133 in_channels, out_channels, kernel_size=3, stride=2, bias=True, dimension=D
134 )
135
136 print(conv)
137 input = SparseTensor(feats, coordinates=coords)
138 conv = conv.double()
139 output = conv(input)
140 print(output)
141
142 device = torch.device("cuda")
143 input = SparseTensor(feats.to(device), coordinates=coords.to(device))
144 conv = conv.to(device)
145 output = conv(input)
146 print(output)
147
148 # Check backward
149 fn = MinkowskiConvolutionFunction()
150
151 grad = output.F.clone().zero_()
152 grad[0] = 1
153 output.F.backward(grad)
154
155 self.assertTrue(
156 gradcheck(
157 fn,
158 (
159 input.F,
160 conv.kernel,
161 conv.kernel_generator,
162 conv.convolution_mode,
163 input.coordinate_map_key,
164 None,
165 input.coordinate_manager,
166 ),
167 )
168 )
169
170 def test(self):
171 print(f"{self.__class__.__name__}: test")

Callers

nothing calls this directly

Calls 10

data_loaderFunction · 0.90
SparseTensorClass · 0.90
gradcheckFunction · 0.90
convFunction · 0.85
doubleMethod · 0.80
requires_grad_Method · 0.80
deviceMethod · 0.80
backwardMethod · 0.45

Tested by

no test coverage detected