Skip to content

Conversation

@robertknight
Copy link
Owner

The implementation of the Split operator was clunky and inefficient as it constructed a dynamically sized set of arguments for TensorBase::slice. Internally rten-tensor had a more ergonomic and efficient API for slicing a tensor along an axis. Expose and add tests for this API, and use it in the Split operator implementation.

This change will also make it easier to add support for the num_outputs attribute in the Split operator.

These methods are useful for splitting a tensor into chunks along a given axis.

In the process `Layout::slice_axis` was changed to add bounds checks on the axis
and range, returning a `SliceError` if these are invalid. This in turn makes
`slice_axis` fail earlier and with a better error if the arguments are invalid.
Using `slice_axis` in this context is more efficient and simpler to use than the
more general-purpose `slice` method.
@robertknight robertknight merged commit 16ae864 into main Apr 9, 2025
2 checks passed
@robertknight robertknight deleted the split-slice-axis branch April 9, 2025 07: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.

2 participants