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

Add contiguous()/try_contiguous() as a method to trait ReshapeTo #679

Closed
Tracked by #577
coreylowman opened this issue Apr 8, 2023 · 0 comments · Fixed by #690
Closed
Tracked by #577

Add contiguous()/try_contiguous() as a method to trait ReshapeTo #679

coreylowman opened this issue Apr 8, 2023 · 0 comments · Fixed by #690
Labels
good first issue Good for newcomers

Comments

@coreylowman
Copy link
Owner

These two methods can just have default implementations of calling reshape:

fn try_contiguous(self) -> Result<Self, D::Err> {
   self.try_reshape_like(self.shape()) 
}

This works because reshape already ensures that output is contiguous, and calling reshape with the same shape of the tensor will ensure it has the same shape.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant