Answering myself, I have found that the problem came because the tensor one_plane_tensor was on GPU and not on CPU. This can be solve just by assigning the output of ‘to’ function to another tensor that will be on CPU.
torch::Tensor tensor_in_cpu = one_plane_tensor.to(torch::kCPU);

and it works.