Skip to content

Document Tensor storage contracts and NumPy differences - #56291

Open
tannergooding wants to merge 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-studious-dollop
Open

tannergooding wants to merge 1 commit into
dotnet:mainfrom
tannergooding:tannergooding-studious-dollop

Conversation

@tannergooding

@tannergooding tannergooding commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Document the Tensor storage contracts and intentional NumPy differences introduced or clarified by dotnet/runtime#134914:

  • Add the compatibility article for unsupported overlapping layouts, repeated-storage destinations, and array element-type validation, with explicit snapshot migration guidance.
  • Add a conceptual Tensor guide covering empty shapes, scalar-like squeeze results, nonnegative strides, default-filled resizing, and operation-specific overlap support.
  • Link the guide from the numerics overview and fundamentals navigation, and add the compatibility article to the version index and compatibility navigation.

This PR is intended to merge alongside the runtime PR. The version helper currently reports .NET 12 Preview 1; the runtime PR has not merged yet, so release placement needs confirmation before merge. This PR covers conceptual and compatibility documentation; API-reference XML belongs to the separate dotnet/dotnet-api-docs repository.

Content sources

The conceptual shape, squeeze, reversal, resize, and empty-stride explanations are adapted from the runtime Tensor README. The overlap table and migration guidance are adapted from the implementation and revised IReadOnlyTensor<TSelf, T> contract. The compatibility article is adapted from #56290. Examples, navigation entries, and the .NET 12 index are newly generated. Please review the operation-specific contracts and release placement.

Validation

Markdownlint reports no issues across all four changed articles. Relative Markdown links and 17 Tensor API cross-references resolve against the source files and API-reference XML.

Built and ran the examples against the accepted runtime implementation at c431dcd84450420a08e07edf94c3be3ecf5988a6:

Example Verified result
First-axis reversal [3, 4, 1, 2]
Explicit snapshot [1, 2, 4, 5]
Copy from the snapshot Destination receives [1, 2, 4, 5]
Unsupported overlapping copy ArgumentException; backing storage remains [1, 2, 3, 4, 5, 6]

OpenPublishing validation will run on this PR.

Resolves #56290

Note

This pull request was generated with GitHub Copilot.


Internal previews

File Preview link
docs/core/compatibility/12.md Learn preview
docs/core/compatibility/core-libraries/12/tensor-storage-layout-validation.md Learn preview
docs/core/compatibility/toc.yml Learn preview
docs/fundamentals/toc.yml Learn preview
docs/standard/numerics.md Learn preview
docs/standard/tensor-shapes-and-storage.md Learn preview

Build report

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

The release placement remains unconfirmed while the associated runtime change is unmerged.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Documents Tensor shape and storage contracts, NumPy differences, and related breaking changes.

Changes:

  • Adds conceptual Tensor guidance and migration examples.
  • Documents storage-layout validation changes.
  • Adds overview and navigation links.
File Description
docs/​standard/​tensor-shapes-and-storage.md Adds Tensor guidance.
docs/​standard/​numerics.md Links the new guide.
docs/​fundamentals/​toc.yml Adds fundamentals navigation.
docs/​core/​compatibility/​toc.yml Adds .NET 12 navigation.
docs/​core/​compatibility/​core-libraries/​12/​tensor-storage-layout-validation.md Documents the breaking change.
docs/​core/​compatibility/​12.md Adds the .NET 12 index.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +85 to +88
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.CopyTo*>.
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.FlattenTo*>.
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.TryCopyTo*>.
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.TryFlattenTo*>.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.CopyTo*>.
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.FlattenTo*>.
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.TryCopyTo*>.
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.TryFlattenTo*>.
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.CopyTo*?displayProperty=fullName>.
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.FlattenTo*?displayProperty=fullName>.
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.TryCopyTo*?displayProperty=fullName>.
- <xref:System.Numerics.Tensors.IReadOnlyTensor`2.TryFlattenTo*?displayProperty=fullName>.

Comment on lines +91 to +93
- <xref:System.Numerics.Tensors.Tensor.ResizeTo*> (all overloads).
- <xref:System.Numerics.Tensors.Tensor.Reverse*> and <xref:System.Numerics.Tensors.Tensor.ReverseDimension*> (overloads that take a destination).
- <xref:System.Numerics.Tensors.Tensor.Concatenate*> (overload that takes a destination).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- <xref:System.Numerics.Tensors.Tensor.ResizeTo*> (all overloads).
- <xref:System.Numerics.Tensors.Tensor.Reverse*> and <xref:System.Numerics.Tensors.Tensor.ReverseDimension*> (overloads that take a destination).
- <xref:System.Numerics.Tensors.Tensor.Concatenate*> (overload that takes a destination).
- <xref:System.Numerics.Tensors.Tensor.ResizeTo*?displayProperty=fullName> (all overloads).
- <xref:System.Numerics.Tensors.Tensor.Reverse*?displayProperty=fullName> and <xref:System.Numerics.Tensors.Tensor.ReverseDimension*?displayProperty=fullName> (overloads that take a destination).
- <xref:System.Numerics.Tensors.Tensor.Concatenate*?displayProperty=fullName> (overload that takes a destination).

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.

[Breaking change]: Tensor operations reject unsupported storage layouts

3 participants