(self)
| 247 | |
| 248 | class TestConvolutionMode(unittest.TestCase): |
| 249 | def test_gpu(self): |
| 250 | print(f"{self.__class__.__name__}: test_gpu") |
| 251 | if not torch.cuda.is_available(): |
| 252 | return |
| 253 | in_channels, out_channels, D = 3, 2, 2 |
| 254 | coords, feats, labels = data_loader(in_channels, batch_size=20) |
| 255 | feats = feats.double() |
| 256 | feats.requires_grad_() |
| 257 | device = torch.device("cuda") |
| 258 | conv = ( |
| 259 | MinkowskiConvolution( |
| 260 | in_channels, |
| 261 | out_channels, |
| 262 | kernel_size=2, |
| 263 | stride=1, |
| 264 | bias=False, |
| 265 | dimension=D, |
| 266 | ) |
| 267 | .to(device) |
| 268 | .double() |
| 269 | ) |
| 270 | # Initialize context |
| 271 | for mode in [_C.ConvolutionMode.DIRECT_GEMM, _C.ConvolutionMode.COPY_GEMM]: |
| 272 | conv.convolution_mode = mode |
| 273 | input = SparseTensor(feats, coordinates=coords, device=device) |
| 274 | print(mode, input.F.numel(), len(input), input) |
| 275 | output = conv(input) |
| 276 | print(output) |
| 277 | |
| 278 | # Check backward |
| 279 | fn = MinkowskiConvolutionFunction() |
| 280 | |
| 281 | grad = output.F.clone().zero_() |
| 282 | grad[0] = 1 |
| 283 | output.F.backward(grad) |
| 284 | |
| 285 | self.assertTrue( |
| 286 | gradcheck( |
| 287 | fn, |
| 288 | ( |
| 289 | input.F, |
| 290 | conv.kernel, |
| 291 | conv.kernel_generator, |
| 292 | conv.convolution_mode, |
| 293 | input.coordinate_map_key, |
| 294 | None, |
| 295 | input.coordinate_manager, |
| 296 | ), |
| 297 | ) |
| 298 | ) |
| 299 | |
| 300 | |
| 301 | class TestConvolutionTranspose(unittest.TestCase): |
nothing calls this directly
no test coverage detected