NVIDIA / MinkowskiEngine

Minkowski Engine is an auto-diff neural network library for high-dimensional sparse tensors
https://nvidia.github.io/MinkowskiEngine
Other
2.48k stars 368 forks source link

Empty SparseTensor convolution segfault #591

Open francois-drielsma opened 6 months ago

francois-drielsma commented 6 months ago

Describe the bug When passing an empty SparseTensor object through a MinkowskiConvolution, MinkowskiEngine throws a segfault.


To Reproduce Docker image: deeplearnphysics/larcv2:ub20.04-cuda12.1-pytorch2.2.1-larndsim

Code snippet

import torch
import MinkowskiEngine as ME

input = ME.SparseTensor(coordinates=torch.empty(0,4).to(dtype=torch.int), features=torch.empty(0,1))
conv = ME.MinkowskiConvolution(in_channels=1, out_channels=3, dimension=3, kernel_size=3)
conv(input)

Expected behavior Would hope for an empty output with the appropriate number of features, e.g.:

SparseTensor(
  coordinates=tensor([], size=(0, 4), dtype=torch.int32)
  features=tensor([], size=(0, 3), grad_fn=<MinkowskiConvolutionFunctionBackward>)
  coordinate_map_key=coordinate map key:[1, 1, 1]
  coordinate_manager=CoordinateMapManagerCPU(
    [1, 1, 1, ]:  CoordinateMapCPU:0x4
    algorithm=MinkowskiAlgorithm.DEFAULT
  )
  spatial dimension=3)

Desktop (please complete the following information):

==========MinkowskiEngine========== 0.5.4 MinkowskiEngine compiled with CUDA Support: True NVCC version MinkowskiEngine is compiled: 12010 CUDART version MinkowskiEngine is compiled: 12010



************************************************************************************
**Additional context**
I did not do extensive version testing, but this seems to work for torch 1.13 in an older container: deeplearnphysics/larcv2:ub20.04-cuda11.6-pytorch1.13-larndsim
francois-drielsma commented 6 months ago

Having a similar issue with MinkowskiConvolutionTranspose, even with the older version of PyTorch. This:

import torch
import MinkowskiEngine as ME

input = ME.SparseTensor(coordinates=torch.empty(0,4).to(dtype=torch.int), features=torch.empty(0,1))
conv = ME.MinkowskiConvolution(in_channels=1, out_channels=4, kernel_size=[2, 2, 2], stride=[2, 2, 2], dilation=[1, 1, 1], dimension=3)
conv_t = ME.MinkowskiConvolutionTranspose(in_channels=4, out_channels=4, kernel_size=[2, 2, 2], stride=[2, 2, 2], dilation=[1, 1, 1], dimension=3)
x = conv(input)
x = conv_t(x)

throws a segfault on the last line.