def test_avgpooling_gpu(self): if not torch.cuda.is_available(): return in_channels, D = 2, 2 coords, feats, labels = data_loader(in_channels) feats = feats.double() feats.requires_grad_() input = SparseTensor(feats, coords=coords) pool = MinkowskiAvgPooling(kernel_size=3, stride=2, dimension=D) output = pool(input) print(output) device = torch.device('cuda') with torch.cuda.device(0): input = input.to(device) pool = pool.to(device) output = pool(input) print(output) # Check backward fn = MinkowskiAvgPoolingFunction() self.assertTrue( gradcheck( fn, (input.F, input.tensor_stride, pool.stride, pool.kernel_size, pool.dilation, pool.region_type_, pool.region_offset_, True, input.coords_key, None, input.coords_man)))
def test_unpooling_gpu(self): if not torch.cuda.is_available(): return in_channels, out_channels, D = 2, 3, 2 coords, feats, labels = data_loader(in_channels) feats = feats.double() input = SparseTensor(feats, coords=coords) conv = MinkowskiConvolution(in_channels, out_channels, kernel_size=3, stride=2, dimension=D) conv = conv.double() unpool = MinkowskiPoolingTranspose(kernel_size=3, stride=2, dimension=D) input = conv(input) output = unpool(input) print(output) # Check backward fn = MinkowskiPoolingTransposeFunction() self.assertTrue( gradcheck(fn, (input.F, input.tensor_stride, unpool.stride, unpool.kernel_size, unpool.dilation, unpool.region_type_, unpool.region_offset_, False, input.coords_key, None, input.coords_man))) device = torch.device('cuda') with torch.cuda.device(0): input = input.to(device) output = unpool(input) print(output) # Check backward fn = MinkowskiAvgPoolingFunction() self.assertTrue( gradcheck(fn, (input.F, input.tensor_stride, unpool.stride, unpool.kernel_size, unpool.dilation, unpool.region_type_, unpool.region_offset_, True, input.coords_key, None, input.coords_man)))