Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make TensorBase::{inner_iter, inner_iter_mut} more efficient #259

Merged
merged 1 commit into from
Jun 29, 2024

Conversation

robertknight
Copy link
Owner

@robertknight robertknight commented Jun 29, 2024

The slicing in each call to next was slow. Since these iterators yield views with the same layout each time, we can precompute the layout when the iterator is constructed. Each call to next then just has to compute the storage offset for the next view.

This optimization is not yet implemented for inner_iter_dyn, but in principle it could be.

TODO:

  • Enforce absence of internal overlap in TensorBase::from_storage_and_layout, when the storage is mutable, or change the API

The slicing in each call to `next` was slow. Since these iterators yield views
with the same layout each time, we can precompute the layout when the iterator
is constructed. Each call to `next` then just has to compute the storage offset
for the next view.

This optimization is not yet implemented for `inner_iter_dyn`, but could
be in future.
@robertknight robertknight marked this pull request as ready for review June 29, 2024 21:17
@robertknight robertknight merged commit 7c7d1f4 into main Jun 29, 2024
2 checks passed
@robertknight robertknight deleted the inner-iter-opt branch June 29, 2024 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant