Skip to content

Conversation

@michaelgsharp
Copy link
Contributor

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.

@michaelgsharp michaelgsharp self-assigned this Mar 11, 2025
Copilot AI review requested due to automatic review settings March 11, 2025 23:38
@ghost
Copy link

ghost commented Mar 11, 2025

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
@ghost
Copy link

ghost commented Mar 11, 2025

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 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
Contributor

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