(self)
| 300 | |
| 301 | class TestConvolutionTranspose(unittest.TestCase): |
| 302 | def test_gpu(self): |
| 303 | print(f"{self.__class__.__name__}: test_gpu") |
| 304 | if not torch.cuda.is_available(): |
| 305 | return |
| 306 | |
| 307 | device = torch.device("cuda") |
| 308 | in_channels, out_channels, D = 2, 3, 2 |
| 309 | coords, feats, labels = data_loader(in_channels) |
| 310 | feats = feats.double() |
| 311 | feats.requires_grad_() |
| 312 | input = SparseTensor(feats.to(device), coordinates=coords.to(device)) |
| 313 | # Initialize context |
| 314 | conv = ( |
| 315 | MinkowskiConvolution( |
| 316 | in_channels, |
| 317 | out_channels, |
| 318 | kernel_size=3, |
| 319 | stride=2, |
| 320 | bias=True, |
| 321 | dimension=D, |
| 322 | ) |
| 323 | .double() |
| 324 | .to(device) |
| 325 | ) |
| 326 | conv_tr = ( |
| 327 | MinkowskiConvolutionTranspose( |
| 328 | out_channels, |
| 329 | in_channels, |
| 330 | kernel_size=3, |
| 331 | stride=2, |
| 332 | bias=True, |
| 333 | dimension=D, |
| 334 | ) |
| 335 | .double() |
| 336 | .to(device) |
| 337 | ) |
| 338 | tr_input = conv(input) |
| 339 | print(tr_input) |
| 340 | output = conv_tr(tr_input) |
| 341 | print(output) |
| 342 | |
| 343 | # Check backward |
| 344 | fn = MinkowskiConvolutionTransposeFunction() |
| 345 | |
| 346 | self.assertTrue( |
| 347 | gradcheck( |
| 348 | fn, |
| 349 | ( |
| 350 | tr_input.F, |
| 351 | conv_tr.kernel, |
| 352 | conv_tr.kernel_generator, |
| 353 | conv_tr.convolution_mode, |
| 354 | tr_input.coordinate_map_key, |
| 355 | output.coordinate_map_key, |
| 356 | tr_input.coordinate_manager, |
| 357 | ), |
| 358 | ) |
| 359 | ) |
nothing calls this directly
no test coverage detected