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

Add lots more TensorPrimitives operations #97192

Merged
merged 15 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public static void Exp(ReadOnlySpan<float> x, Span<float> destination) =>
/// </para>
/// </remarks>
public static int IndexOfMax(ReadOnlySpan<float> x) =>
IndexOfMinMaxCore<IndexOfMaxOperator_Single>(x);
IndexOfMinMaxCore<float, IndexOfMaxOperator_Single>(x);

/// <summary>Searches for the index of the single-precision floating-point number with the largest magnitude in the specified tensor.</summary>
/// <param name="x">The tensor, represented as a span.</param>
Expand All @@ -320,7 +320,7 @@ public static int IndexOfMax(ReadOnlySpan<float> x) =>
/// </para>
/// </remarks>
public static int IndexOfMaxMagnitude(ReadOnlySpan<float> x) =>
IndexOfMinMaxCore<IndexOfMaxMagnitudeOperator_Single>(x);
IndexOfMinMaxCore<float, IndexOfMaxMagnitudeOperator_Single>(x);

/// <summary>Searches for the index of the smallest single-precision floating-point number in the specified tensor.</summary>
/// <param name="x">The tensor, represented as a span.</param>
Expand All @@ -336,7 +336,7 @@ public static int IndexOfMaxMagnitude(ReadOnlySpan<float> x) =>
/// </para>
/// </remarks>
public static int IndexOfMin(ReadOnlySpan<float> x) =>
IndexOfMinMaxCore<IndexOfMinOperator_Single>(x);
IndexOfMinMaxCore<float, IndexOfMinOperator_Single>(x);

/// <summary>Searches for the index of the single-precision floating-point number with the smallest magnitude in the specified tensor.</summary>
/// <param name="x">The tensor, represented as a span.</param>
Expand All @@ -353,7 +353,7 @@ public static int IndexOfMin(ReadOnlySpan<float> x) =>
/// </para>
/// </remarks>
public static int IndexOfMinMagnitude(ReadOnlySpan<float> x) =>
IndexOfMinMaxCore<IndexOfMinMagnitudeOperator_Single>(x);
IndexOfMinMaxCore<float, IndexOfMinMagnitudeOperator_Single>(x);

/// <summary>Computes the element-wise natural (base <c>e</c>) logarithm of single-precision floating-point numbers in the specified tensor.</summary>
/// <param name="x">The tensor, represented as a span.</param>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

// This file exists to enable TensorPrimitives.float.cs to be compiled for both
// This file exists to enable TensorPrimitives.Single.cs to be compiled for both
// netstandard2.0 and net8.0+ targets. It uses the XX_Single names and the operation
// methods tied to float, whereas the net8.0+ worker implementations use generic math.
// This file provides float-bound types and type defs that route one to the other.
Expand All @@ -14,6 +14,10 @@
global using DivideOperator_Single = System.Numerics.Tensors.TensorPrimitives.DivideOperator<float>;
global using MultiplyOperator_Single = System.Numerics.Tensors.TensorPrimitives.MultiplyOperator<float>;
global using ExpOperator_Single = System.Numerics.Tensors.TensorPrimitives.ExpOperator<float>;
global using IndexOfMaxOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMaxOperator<float>;
global using IndexOfMaxMagnitudeOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMaxMagnitudeOperator<float>;
global using IndexOfMinOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMinOperator<float>;
global using IndexOfMinMagnitudeOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMinMagnitudeOperator<float>;
global using LogOperator_Single = System.Numerics.Tensors.TensorPrimitives.LogOperator<float>;
global using Log2Operator_Single = System.Numerics.Tensors.TensorPrimitives.Log2Operator<float>;
global using MaxOperator_Single = System.Numerics.Tensors.TensorPrimitives.MaxOperator<float>;
Expand All @@ -33,12 +37,6 @@
global using SquaredOperator_Single = System.Numerics.Tensors.TensorPrimitives.SquaredOperator<float>;
global using TanhOperator_Single = System.Numerics.Tensors.TensorPrimitives.TanhOperator<float>;

// TODO: These should be made generic. Their implementations are still currently bound to float.
global using IndexOfMaxOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMaxOperator;
global using IndexOfMaxMagnitudeOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMaxMagnitudeOperator;
global using IndexOfMinOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMinOperator;
global using IndexOfMinMagnitudeOperator_Single = System.Numerics.Tensors.TensorPrimitives.IndexOfMinMagnitudeOperator;

namespace System.Numerics.Tensors
{
public static unsafe partial class TensorPrimitives
Expand Down
Loading