You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
use tch::{Device,Kind,Tensor};fnmain(){// Columns of a conceptual (6, 3) sparse matrix.let a = Tensor::from_slice(&[7.3,5.5,6.1,3.3]).set_requires_grad(true);let b = Tensor::from_slice(&[8.8,4.6]).set_requires_grad(true);let c = Tensor::from_slice(&[4.9,8.9,6.7]).set_requires_grad(true);// Indices of every columns value.let ia = Tensor::from_slice(&[0,2,3,5]);let ib = Tensor::from_slice(&[1,3]);let ic = Tensor::from_slice(&[1,2,4]);let src = Tensor::cat(&[a, b, c],0);let idx = Tensor::cat(&[ia, ib, ic],0);let rowsums =
Tensor::zeros(6,(Kind::Double,Device::Cpu)).scatter_reduce(0,&idx,&src,"sum");println!("rowsums: {rowsums}");// [7.3, 13.7, 14.4, 10.7, 6.7, 3.3].}
yields
Warning: The reduce argument of torch.scatter with Tensor src is deprecated and will be removed in a future PyTorch release. Use torch.scatter_reduce instead for more reduction options. (function operator())
As it turns out, adding the following lines makes it panic:
let total = rowsums.sum(Kind::Double);
total.backward();
called `Result::unwrap()` on an `Err` value: Torch("derivative for aten::scatter is not implemented")
I eventually figured that the fix is to replace .scatter_reduce(0, &idx, &src, "sum") by .reduce_add(0, &idx, &src), but the whole process has been rather confusing. What is the actual meaning of the warning I had? Is it actually related to the later panic?
The text was updated successfully, but these errors were encountered:
The following program:
yields
As it turns out, adding the following lines makes it panic:
I eventually figured that the fix is to replace
.scatter_reduce(0, &idx, &src, "sum")
by.reduce_add(0, &idx, &src)
, but the whole process has been rather confusing. What is the actual meaning of the warning I had? Is it actually related to the later panic?The text was updated successfully, but these errors were encountered: