Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/coreclr/jit/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2734,7 +2734,7 @@ float FloatingPointUtils::maximumNumber(float x, float y)
//
// It propagates NaN inputs back to the caller and
// otherwise returns the lesser of the inputs. It
// treats +0 as lesser than -0 as per the specification.
// treats +0 as greater than -0 as per the specification.
//
// Arguments:
// val1 - left operand
Expand Down Expand Up @@ -2763,7 +2763,7 @@ double FloatingPointUtils::minimum(double val1, double val2)
//
// It propagates NaN inputs back to the caller and
// otherwise returns the input with a lesser magnitude.
// It treats +0 as lesser than -0 as per the specification.
// It treats +0 as greater than -0 as per the specification.
//
// Arguments:
// x - left operand
Expand Down Expand Up @@ -2856,7 +2856,7 @@ double FloatingPointUtils::minimumNumber(double x, double y)
//
// It propagates NaN inputs back to the caller and
// otherwise returns the lesser of the inputs. It
// treats +0 as lesser than -0 as per the specification.
// treats +0 as greater than -0 as per the specification.
//
// Arguments:
// val1 - left operand
Expand Down Expand Up @@ -2885,7 +2885,7 @@ float FloatingPointUtils::minimum(float val1, float val2)
//
// It propagates NaN inputs back to the caller and
// otherwise returns the input with a lesser magnitude.
// It treats +0 as lesser than -0 as per the specification.
// It treats +0 as greater than -0 as per the specification.
//
// Arguments:
// x - left operand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public UnixImplementation(int elementCount)

public override bool IsReadonly => false;

public override int Length => _elementCount;

public override Memory<T> Memory => _memoryManager.Memory;

public override Span<T> Span
Expand Down Expand Up @@ -83,10 +85,7 @@ protected override void Dispose(bool disposing)
// no-op; the handle will be disposed separately
}

public override Span<T> GetSpan()
{
throw new NotImplementedException();
}
public override Span<T> GetSpan() => _impl.Span;

public override MemoryHandle Pin(int elementIndex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ internal WindowsImplementation(VirtualAllocHandle handle, int byteOffsetIntoHand

public override bool IsReadonly => (Protection != VirtualAllocProtection.PAGE_READWRITE);

public override int Length => _elementCount;

internal VirtualAllocProtection Protection
{
get
Expand Down Expand Up @@ -189,10 +191,7 @@ protected override void Dispose(bool disposing)
// no-op; the handle will be disposed separately
}

public override Span<T> GetSpan()
{
throw new NotImplementedException();
}
public override Span<T> GetSpan() => _impl.Span;

public override MemoryHandle Pin(int elementIndex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ public abstract class BoundedMemory<T> : IDisposable where T : unmanaged
/// </summary>
public abstract bool IsReadonly { get; }

/// <summary>Gets the length of the <see cref="BoundedMemory{T}"/> instance.</summary>
public abstract int Length { get; }

/// <summary>
/// Gets the <see cref="Memory{Byte}"/> which represents this native memory.
/// This <see cref="BoundedMemory{T}"/> instance must be kept alive while working with the <see cref="Memory{Byte}"/>.
Expand Down Expand Up @@ -44,5 +47,23 @@ public abstract class BoundedMemory<T> : IDisposable where T : unmanaged
/// OS does not support marking the memory block as read+write.
/// </summary>
public abstract void MakeWriteable();

/// <summary>
/// Gets the <see cref="Span{Byte}"/> which represents this native memory.
/// This <see cref="BoundedMemory{T}"/> instance must be kept alive while working with the <see cref="Span{Byte}"/>.
/// </summary>
public static implicit operator Span<T>(BoundedMemory<T> boundedMemory) => boundedMemory.Span;

/// <summary>
/// Gets the <see cref="ReadOnlySpan{Byte}"/> which represents this native memory.
/// This <see cref="BoundedMemory{T}"/> instance must be kept alive while working with the <see cref="ReadOnlySpan{Byte}"/>.
/// </summary>
public static implicit operator ReadOnlySpan<T>(BoundedMemory<T> boundedMemory) => boundedMemory.Span;

/// <summary>
/// Gets a reference to the element at the specified index.
/// This <see cref="BoundedMemory{T}"/> instance must be kept alive while working with the reference.
/// </summary>
public ref T this[int index] => ref Span[index];
}
}
17 changes: 16 additions & 1 deletion src/libraries/Microsoft.Bcl.Numerics/src/PACKAGE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,22 @@ As of .NET Core 2.0 and .NET Standard 2.1, the C# language has support for math

## How to Use

<!-- A compelling example on how to use this package with code, as well as any specific guidelines for when to use the package -->
```C#
using System;
using System.MathF.

internal static class Program
{
private static async Task Main()
{
Console.WriteLine("Starting...");

Console.WriteLine(MathF.Max(1f, 5f)); // returns 5f

Console.WriteLine("Finished!");
}
}
```

```C#
using System;
Expand Down
8 changes: 0 additions & 8 deletions src/libraries/System.Numerics.Tensors/Directory.Build.props

This file was deleted.

3 changes: 2 additions & 1 deletion src/libraries/System.Numerics.Tensors/README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# System.Numerics.Tensors
This library has not been shipped publicly and is not accepting contributions at this time.

Provides APIs for performing primitive operations over tensors represented by spans of memory.
Loading