(self)
| 594 | |
| 595 | class TestPCD(unittest.TestCase): |
| 596 | def test_forward(self): |
| 597 | coords, colors, pcd = load_file("1.ply") |
| 598 | device = "cuda" |
| 599 | |
| 600 | X = [] |
| 601 | Y = [] |
| 602 | W = [] |
| 603 | for IC in [3, 8, 16, 24, 32, 48, 64, 96, 128]: |
| 604 | for OC in [3, 8, 16, 24, 32, 48, 64, 96, 128, 192, 256]: |
| 605 | for batch_size in [1, 5, 10, 15, 20]: |
| 606 | for voxel_size in [0.2, 0.1, 0.075, 0.05, 0.025]: |
| 607 | min_times = [] |
| 608 | for mode in [ |
| 609 | _C.ConvolutionMode.DIRECT_GEMM, |
| 610 | _C.ConvolutionMode.COPY_GEMM, |
| 611 | ]: |
| 612 | min_time = 100000 |
| 613 | dcoords = torch.from_numpy( |
| 614 | np.floor(coords / voxel_size) |
| 615 | ).int() |
| 616 | bcoords = batched_coordinates( |
| 617 | [dcoords for i in range(batch_size)] |
| 618 | ) |
| 619 | in_feats = torch.rand(len(bcoords), IC).to(0) |
| 620 | sinput = SparseTensor( |
| 621 | in_feats, coordinates=bcoords, device=device |
| 622 | ) |
| 623 | conv = MinkowskiConvolution( |
| 624 | in_channels=IC, |
| 625 | out_channels=OC, |
| 626 | kernel_size=3, |
| 627 | stride=2, |
| 628 | convolution_mode=mode, |
| 629 | dimension=3, |
| 630 | ).to(device) |
| 631 | soutput = conv(sinput) |
| 632 | loss = soutput.F.sum() |
| 633 | for i in range(10): |
| 634 | stime = time.time() |
| 635 | loss.backward() |
| 636 | min_time = min(time.time() - stime, min_time) |
| 637 | min_times.append(min_time) |
| 638 | |
| 639 | X.append( |
| 640 | [ |
| 641 | IC, |
| 642 | OC, |
| 643 | len(sinput), |
| 644 | len(soutput), |
| 645 | ] |
| 646 | ) |
| 647 | Y.append(np.argmin(min_times)) |
| 648 | W.append(np.abs(min_times[0] - min_times[1])) |
| 649 | print(X[-1], Y[-1], W[-1]) |
| 650 | |
| 651 | import pickle as pkl |
| 652 | |
| 653 | with open("forward-speed.pkl", "wb") as f: |
nothing calls this directly
no test coverage detected