RuntimeError when using scatter_std
See original GitHub issuehi @rusty1s ,
I am trying to update some pyg code written one year ago to make it work with newer versions of packages.
While testing my code (which used to work), I encountered the following error when calling scatter_std
:
Traceback (most recent call last): File “”, line 1, in <module> RuntimeError: The following operation failed in the TorchScript interpreter. Traceback of TorchScript (most recent call last): File “/home/tformal/wisard_debug/lib/python3.7/site-packages/torch_scatter/composite/std.py”, line 29, in scatter_std index = broadcast(index, src, dim) tmp = scatter_sum(src, index, dim, dim_size=dim_size) count = broadcast(count, tmp, dim).clamp_(1) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <— HERE mean = tmp.div(count) RuntimeError: unsupported operation: more than one element of the written-to tensor refers to a single memory location. Please clone() the tensor before performing the operation.
I have the same error with the toy example:
import torch
from torch_scatter import scatter_std
data = torch.rand(5, 4)
index = torch.tensor([0, 0, 0, 1, 1])
scatter_std(src=data, index=index, dim=0)
packages versions: >>> torch_scatter.__version__ ‘2.0.4’ >>> torch.__version__ ‘1.5.0’
what I want to do is normalize node features in my graph, so I need to compute scatter std. Did something change regarding this function ?
thanks in advance
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (3 by maintainers)
Just released a new version of the package 😃
I can confirm this, really sorry. It is fixed in master. For a quick fix, you can just replace
clamp_
byclamp
in thestd.py
file.