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

Fixing SetSlice, Reshape, TryCopyTo. #107852

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

michaelgsharp
Copy link
Member

Fixes #106539, #106537, and #106535.

They all had to go in one PR as they were all connected, but basically fixes Reshape/SetSlice to work with 0 strides. Also adds a few more checks to make sure its ok to Reshape the values.

@soerenwolfers
Copy link

With this proposal, the definition of Reshape would be sufficiently restrictive that I think

  • the documentation should be extended to specify in more detail what "the new shape is not compatible with the old shape" means
  • the functionality should be hidden behind a TryReshape method.

Also, note that the bit where numpy and the current TensorSpan deviate in #106539 is just a.Reshape(a.Lengths), on which numpy returns a whereas the proposal here would throw an exception, which it should probably not (although maybe there is a reasonable definition of Reshape that doesn't allow it and I just don't see it, see the first bullet point).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

System.Numerics.Tensors Should omit .Reshape function.
3 participants