Skip to content

Added in non-generic interfaces for Tensors #113401

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

Merged
merged 4 commits into from
Mar 14, 2025

Conversation

michaelgsharp
Copy link
Member

Fixes #111968 and fixes #111966

Addes in gon-generic interfaces for tensors that let you do basic operations.
Also adds in the ability to pin the backing memory.

Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

1 similar comment
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces non-generic tensor interfaces and updates tensor implementations to support basic operations such as index access via object indexers, memory pinning, and filling using object values. Key changes include:

  • Replacing the generic IReadOnlyTensor<TSelf, T> with a non-generic IReadOnlyTensor interface.
  • Introducing object-based indexers and methods for pinning backing memory.
  • Updating tests to cover the new object API and memory pinning functionality.

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/IReadOnlyTensor.cs Replaces the generic interface with a non-generic version and adds new properties/methods (Lengths, Strides, indexers, GetPinnedHandle).
src/libraries/System.Numerics.Tensors/tests/TensorTests.cs Adds new tests for object-based filling, index access, and pinned memory handling.
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/ITensor.cs Updates the ITensor interface to inherit from the non-generic IReadOnlyTensor and includes new signatures for indexers and Fill.
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/Tensor.cs Adjusts the Tensor implementation to support the new non-generic interfaces and implements the GetPinnedHandle and object-based Fill methods.
src/libraries/System.Numerics.Tensors/ref/System.Numerics.Tensors.netcore.cs Updates the reference assemblies to reflect changes in the interfaces and class signatures.

/// <summary>
/// Pins and gets a <see cref="MemoryHandle"/> to the backing memory.
/// </summary>
/// <returns><see cref="MemoryHandle"/></returns>
Copy link
Member

Choose a reason for hiding this comment

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

Missing return doc.

@michaelgsharp michaelgsharp merged commit f0f1457 into dotnet:main Mar 14, 2025
82 of 84 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Apr 14, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[API Proposal]: Non-generic Tensor base type [API Proposal]: GetPinnedHandle for tensors
3 participants