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 various iterators generic over the tensor layout #40

Merged
merged 11 commits into from
Jan 14, 2024

Conversation

robertknight
Copy link
Owner

@robertknight robertknight commented Jan 14, 2024

This PR contains some preparation for unifying the TensorBase and NdTensorBase structs, in order to enforce a more consistent API between them.

There are also some small API changes to the existing APIs of NdLayout/DynLayout and TensorBase/NdTensorBase to prepare for a unified API, including some removal of APIs that are no longer used internally.

…ndex`

A layout has two functions: 1) defining the shape of a tensor and 2) the mapping
between indices and offsets. Given (2), a method to map between index and offset
is something the trait should obviously have, and enables writing more code that
works generically with different layouts. Adding this required removing some
bounds from `Layout::Index` which are apparently not needed any longer.
The same thing can be accomplished by converting to a static view with
`Tensor::nd_view` and then slicing.
This aligns with `into_shape`.
This trait was just a wrapper around `AsRef<[usize]>`. The indirection doesn't
appear to be useful any more.
This enables using it for `NdLayout`.
This will enable using them with NdLayout.
This is work towards unifying `NdTensorBase` and `TensorBase` into one struct.
This enables writing methods like `NdTensor::get` that are generic over
the layout.
@robertknight robertknight merged commit fb6b9c8 into main Jan 14, 2024
1 check passed
@robertknight robertknight deleted the layout-offset-fn branch January 14, 2024 15:42
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