torch::Tensor a = torch::ones({10}, torch::TensorOptions().dtype(torch::kI64));
torch::Tensor b = torch::zeros({3}, torch::TensorOptions().dtype(torch::kI64));
torch::Tensor torchIdx_test = at::tensor({0,2,7}).toType(torch::kInt64);
a.index_put({torchIdx_test}, b);
std::cout << a<<std::endl;
but the result is not as expect
1
1
1
1
1
1
1
1
1
1
[ CPULongType{10} ]
however
a = a.index_put({torchIdx_test}, b);
it will work as expectation
0
1
0
1
1
1
1
0
1
1
[ CPULongType{10} ]
I wonder is there any in-place operation? If not, is “=” operation will do real copy of memory?
Btw, I also tried operation like “a.index() = b”. it didn’t work either.