mit-han-lab / torchsparse

[MICRO'23, MLSys'22] TorchSparse: Efficient Training and Inference Framework for Sparse Convolution on GPUs.
https://torchsparse.mit.edu
MIT License
1.22k stars 143 forks source link

spatial_range, what is it and how to specify? #310

Closed Tortoise0Knight closed 3 months ago

Tortoise0Knight commented 5 months ago

When I'm doing a generative transpose convolution on a tensor. An error occured: AssertionError: spatial range must be specified in generative mode This seems to because I didn't specify the spatial_range when creating sparse tensor.

My sparse tensor is converted from a MinkowskiEngine SparseTensor by:

def minkowski_to_torchsparse_sparse_tensor(sparse_tensor: ME.SparseTensor) -> torchsparse.SparseTensor:
    """Convert the MinkowskiEngine SparseTensor to torchsparse SparseTensor"""
    coords = sparse_tensor.C
    feats = sparse_tensor.F
    tensor_stride = sparse_tensor.tensor_stride
    col_indices = torch.tensor([3, 0, 1, 2], device=coords.device)
    coords = torch.index_select(coords, 1, col_indices)
    out = torchsparse.SparseTensor(coords=coords, feats=feats, stride=tensor_stride)
    return out

I don't know what does this spatial_range mean and how to specify it when converting from a MinkowskiEngine SparseTensor.

zhijian-liu commented 3 months ago

To understand sparse tensors, imagine a tensor with many zero elements. If you have a dense 3D tensor with dimensions HxWxL, defining a sparse tensor means that the spatial range of your tensor remains (H, W, L), but many of the values within this range are zero.

Tortoise0Knight commented 3 months ago

To understand sparse tensors, imagine a tensor with many zero elements. If you have a dense 3D tensor with dimensions HxWxL, defining a sparse tensor means that the spatial range of your tensor remains (H, W, L), but many of the values within this range are zero.

Thank you for your explanation! So this value numerically equals to the maximum value along 3 dimensions.