I want to update a 2-dimensional slice of a 3D tensor in libtorch.
I have made an accessor for this 3D tensor.
-
Would it be quicker to use the accessor to populate the 2D slice? Rather than doing what I was doing up until now, i.e.:
Psi_spec.index_put_( {i, Slice(), Slice()}, zero_imag_tensor );
-
If this is the case, how shall use the accessor to obtain what I obtain with the code above at 1. ?
Psi_spec_acc.index_put_( {i, Slice(), Slice()}, zero_imag_tensor );
fails.
Similarly,Psi_spec_acc[i] = zero_imag_tensor;
fails as well.
Moreover,Psi_spec_acc[i][][] = zero_imag_tensor;
fails again.
For completeness:
torch::Tensor zero_imag_tensor = torch::zeros( {1}, torch::TensorOptions().dtype(torch::kComplexDouble) );