Hello, sorry to bother you.
I’m having a problem with scatter_min, specifically a dimensionality issue.
min_dist, min_idx = scatter_min(
dist_all,
cell_id,
dim=0,
dim_size=14225224
)
dist_all.shape = dist_all.shape= torch.Size([287862955])
However, min_idx.max() = 287862955, causing dimensionality errors in my subsequent work. Is this a hidden bug in Torch?
Hi!
You’re talking about the scatter_min function of the library pytorch_scatter, right?
If I understand it correctly, min_idx should only contain indices within dist_all, and 287862955 is exactly the length of the dist_all vector, so 1 unit too large to be a valid index. So it does seem like a bug.
Could you check that cell_id does contain all values up to dim_size - 1? Otherwise, you would have some empty groups: indices in the output tensor associated with no value in the input tensor, which may be the cause for having an invalid index in the output.
I would suggest to:
- Find a minimal reproducer (a block of code with everything inside, including imports, that you can just copy-paste to reproduce the bug). Ideally it should be as simple as possible while still triggering the bug (i.e. much smaller input tensors, default dim and dim_size, if possible), so that it’s easier to find out what went wrong. You can post it here for further help.
- File an issue in their repo (Issues · rusty1s/pytorch_scatter · GitHub). Even if it’s a “wrong” usage from your side (e.g. cell_id with empty groups), they could still either explain in their doc what happens when there are empty groups, or raise an error in such a case.