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

Replace old tensor slicing methods with new API #367

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

robertknight
Copy link
Owner

@robertknight robertknight commented Sep 20, 2024

Remove the old TensorBase::{slice, slice_mut, slice_dyn, slice_mut_dyn} implementations and replace them with the slice_with APIs that infer the result layout type based on the input layout and slice range.

This now leaves the API with a smaller and easier to use set of methods for slicing, which automatically infer the output view's layout:

// Slice static or dynamic rank tensor, return a view that is
// static or dynamic rank respectively.
tensor.slice((.., 1, 2))

// Same, but returns a result
tensor.try_slice((.., 1, 2))

// Same, but returns a mutable view
tensor.slice_mut((.., 1, 2))

// Same, but returns a mutable view in a result
tensor.try_slice_mut((.., 1, 2))

Remove the old `TensorBase::{slice, slice_mut, slice_dyn, slice_mut_dyn}`
implementations and replace them with the `slice_with` APIs that infer the
result layout type based on the input layout and slice range.

This now leaves the API with a smaller and easier to use set of methods for
slicing, which automatically infer the output view's layout.
@robertknight robertknight merged commit cf01e7b into main Sep 20, 2024
2 checks passed
@robertknight robertknight deleted the replace-slice-with-slice-with branch September 20, 2024 07: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