NVIDIA / MinkowskiEngine

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

Unable to Perform Operations on 1-Dimensional Vectors Using MinkowskiEngine #545

Open yunongLiu1 opened 1 year ago

yunongLiu1 commented 1 year ago

Describe the bug

Hello,

I am working on a project that involves performing operations on 1-dimensional vectors using sparse tensor auto-differentiation. I am trying to use MinkowskiEngine to perform vector addition and dot product on 1-dimensional vectors and measure the time taken for these operations. However, I am encountering issues when trying to create ME.SparseTensor with 1-dimensional coordinates.


To Reproduce

Here is the code snippet that I am using:

import torch import MinkowskiEngine as ME import time

Define two sparse tensors with 1-dimensional coordinates

coords1 = torch.IntTensor([[0], [1], [2], [3]]) feats1 = torch.FloatTensor([[1], [2], [3], [4]])

coords2 = torch.IntTensor([[2], [3], [4], [5]]) feats2 = torch.FloatTensor([[5], [6], [7], [8]])

3 Convert to MinkowskiEngine Sparse Tensors

sparse_tensor1 = ME.SparseTensor(features=feats1, coordinates=coords1, coordinate_manager=ME.CoordinateManager(D=1)) sparse_tensor2 = ME.SparseTensor(features=feats2, coordinates=coords2, coordinate_manager=ME.CoordinateManager(D=1))

Sparse Vector Addition

added = sparse_tensor1 + sparse_tensor2

Sparse Vector Dot Product

elementwise_mul = sparse_tensor1 * sparse_tensor2 dot_product = elementwise_mul.F.sum() `

When running this code, I receive the following error:

File "/lib/python3.8/site-packages/MinkowskiEngine-0.5.4-py3.8-linux-x86_64.egg/MinkowskiEngine/MinkowskiCoordinateManager.py", line 122, in init raise ValueError(f"Invalid rank D > 0, D = {D}.") ValueError: Invalid rank D > 0, D = 0.

I understand that MinkowskiEngine is primarily designed for high-dimensional data, but I am specifically interested in using it for 1-dimensional vectors for comparison purposes in my project.

Could you please guide me on how to properly use MinkowskiEngine for operations on 1-dimensional vectors? Any help would be greatly appreciated.

Thank you!