Fix TensorExtensions.StdDev by lilinus · Pull Request #110392 · dotnet/runtime · GitHub
Skip to content

Fix TensorExtensions.StdDev#110392

Merged
michaelgsharp merged 6 commits into
dotnet:mainfrom
lilinus:fix-tensor-stddev
Dec 11, 2024
Merged

Fix TensorExtensions.StdDev#110392
michaelgsharp merged 6 commits into
dotnet:mainfrom
lilinus:fix-tensor-stddev

Conversation

@lilinus

@lilinus lilinus commented Dec 4, 2024

Copy link
Copy Markdown
Contributor

Fixes #110381

I use IPowerFunctions<T>.Pow(x, 0.5) to replicate sqrt, but special case double and float to use Math.Sqrt and MathF.Sqrt respectively.

Would prefer to add IRootFunctions to method constraints to use T.Sqrt but I don't know if it is possible to add new constraints.

N.b. TensorExtensions is still marked as experimental

@dotnet-policy-service dotnet-policy-service Bot added the community-contribution Indicates that the PR has been added by a community member label Dec 4, 2024
@michaelgsharp michaelgsharp merged commit 9bededd into dotnet:main Dec 11, 2024

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should indeed be updated to use IRootFunctions instead; not Pow which isn't guaranteed to behave the same in many important edge cases

@hez2010

hez2010 commented Dec 11, 2024

Copy link
Copy Markdown
Contributor

hez2010 pushed a commit to hez2010/runtime that referenced this pull request Dec 14, 2024
* Fix TensorExtensions.StdDev

* Add constraint to ref

* Revert "Add constraint to ref"

This reverts commit f740f50.

* Revert "Fix TensorExtensions.StdDev"

This reverts commit c212984.

* Use pow method

* Use existing variable
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 11, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-System.Numerics.Tensors community-contribution Indicates that the PR has been added by a community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TensorTests.cs and Tensor.cs StdDev calculates Variance rather than Standard deviations

4 participants