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
Speed/clean up the general_transpose function (in tensor.cc). Currently the last for loop in
Tensor Tensor::general_transpose(const std::vector<size_t>& axes) const
{
if (axes.size() != ndim()) {
throw std::invalid_argument("Invalid axes permutation");
}
std::vector<size_t> transposed_shape(ndim());
for (size_t i = 0; i < ndim(); ++i) {
transposed_shape[i] = shape_[axes[i]];
}
// std::shared_ptr<Tensor> transposed_tensor(new Tensor(transposed_shape));
Tensor transposed_tensor(transposed_shape);
std::complex<double>* transposed_data = transposed_tensor.data().data();
// const std::complex<double>* original_data = data_.data();
// This works but probably can be made more efficient.
// Fix if it turns out to be a bottleneck
for (size_t i = 0; i < size_; i++){
std::vector<size_t> tidx_trans = vidx_to_tidx(i);
size_t t_vidx = transposed_tensor.tidx_to_trans_vidx(tidx_trans, axes);
transposed_data[t_vidx] = data_[i];
}
return transposed_tensor;
}
is maybe doing too much work, if you have time and see a way to optimize then give it a try. Try to transpose a large tensor (30x30x30x30) or someting and see if it is faster.
The text was updated successfully, but these errors were encountered:
Speed/clean up the general_transpose function (in tensor.cc). Currently the last for loop in
is maybe doing too much work, if you have time and see a way to optimize then give it a try. Try to transpose a large tensor (30x30x30x30) or someting and see if it is faster.
The text was updated successfully, but these errors were encountered: