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

Method test_backward

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

Source from the content-addressed store, hash-verified

654 pkl.dump([X, Y, W], f)
655
656 def test_backward(self):
657 coords, colors, pcd = load_file("1.ply")
658 device = "cuda"
659
660 X = []
661 Y = []
662 W = []
663 for IC in [8, 16, 24, 32, 48, 64, 96, 128]:
664 for OC in [8, 16, 24, 32, 48, 64, 96, 128, 192, 256]:
665 for batch_size in [1, 5, 10, 15, 20]:
666 for voxel_size in [0.2, 0.1, 0.075, 0.05, 0.025]:
667 min_times = []
668 for mode in [
669 _C.ConvolutionMode.DIRECT_GEMM,
670 _C.ConvolutionMode.COPY_GEMM,
671 ]:
672 min_time = 100000
673 dcoords = torch.from_numpy(
674 np.floor(coords / voxel_size)
675 ).int()
676 bcoords = batched_coordinates(
677 [dcoords for i in range(batch_size)]
678 )
679 in_feats = torch.rand(len(bcoords), IC).to(0)
680 sinput = SparseTensor(
681 in_feats, coordinates=bcoords, device=device
682 )
683 conv = MinkowskiConvolution(
684 in_channels=IC,
685 out_channels=OC,
686 kernel_size=3,
687 stride=2,
688 convolution_mode=mode,
689 dimension=3,
690 ).to(device)
691 soutput = conv(sinput)
692 loss = soutput.F.sum()
693 for i in range(5):
694 stime = time.time()
695 loss.backward()
696 min_time = min(time.time() - stime, min_time)
697 min_times.append(min_time)
698
699 X.append(
700 [
701 IC,
702 OC,
703 len(sinput),
704 len(soutput),
705 ]
706 )
707 Y.append(np.argmin(min_times))
708 W.append(np.abs(min_times[0] - min_times[1]))
709 print(X[-1], Y[-1], W[-1])
710 import pickle as pkl
711
712 with open("backward-speed.pkl", "wb") as f:
713 pkl.dump([X, Y, W], f)

Callers

nothing calls this directly

Calls 7

load_fileFunction · 0.90
batched_coordinatesFunction · 0.90
SparseTensorClass · 0.90
convFunction · 0.85
appendMethod · 0.80
backwardMethod · 0.45

Tested by

no test coverage detected