Skip to content

Commit

Permalink
Fix TensorPrimitives.IndexOfXx corner-case when first element is seed…
Browse files Browse the repository at this point in the history
… value (dotnet#93169)

* Fix TensorPrimitives.IndexOfXx corner-case when first element is seed value

Found as part of adding more tests for Min/Max{Magnitude} to validate they match their IndexOfXx variants.

* Address PR feedback
  • Loading branch information
stephentoub authored and michaelgsharp committed Oct 20, 2023
1 parent cd02aa5 commit fffa1d4
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ public static int IndexOfMax(ReadOnlySpan<float> x)

if (!x.IsEmpty)
{
result = 0;
float max = float.NegativeInfinity;

for (int i = 0; i < x.Length; i++)
Expand Down Expand Up @@ -370,6 +371,7 @@ public static int IndexOfMaxMagnitude(ReadOnlySpan<float> x)

if (!x.IsEmpty)
{
result = 0;
float max = float.NegativeInfinity;
float maxMag = float.NegativeInfinity;

Expand Down Expand Up @@ -423,6 +425,7 @@ public static int IndexOfMin(ReadOnlySpan<float> x)

if (!x.IsEmpty)
{
result = 0;
float min = float.PositiveInfinity;

for (int i = 0; i < x.Length; i++)
Expand Down Expand Up @@ -473,6 +476,7 @@ public static int IndexOfMinMagnitude(ReadOnlySpan<float> x)

if (!x.IsEmpty)
{
result = 0;
float min = float.PositiveInfinity;
float minMag = float.PositiveInfinity;

Expand Down
Loading

0 comments on commit fffa1d4

Please sign in to comment.