NVIDIA / MinkowskiEngine

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

Checking whether coords is an instance of Sequence seems to be unnecessary #427

Closed taochenshh closed 2 years ago

taochenshh commented 2 years ago

Suppose I have a list of coords that are in the form of numpy array or torch tensor. For example, instead of having a list of point cloud, I have an array of point cloud A that has the shape of [200, 5000, 3] where 200 is the number of point cloud, 5000 is the number of points per point cloud. With the current code (sparse_collate), it seems that I need to first convert this array into a list using something like list(A) first before it's passed to sparse_collate. However, the asserts here are not necessary and the conversion to the list is unnecessary. I wonder what's the logic behind these assertions or perhaps we can add another assertion that allows coords to be a numpy or torch array with ndim=3.

taochenshh commented 2 years ago

If the coords are torch array, sparse_collate still works if we don't have the assertions.

x = torch.randn(10, 200, 3)
y = torch.randn(10, 200, 3)
xb, yb = sparse_collate(x,y) # here I commented out the assertions
xb2, yb2 = sparse_collate(list(x), list(y))
torch.eq(xb, xb2).all()