Skip to content

fix: performance of erfinv #7568 (from dotnet/machinelearning#7569)#51

Draft
Copilot wants to merge 1 commit into
mainfrom
copilot/copy-changes-from-pr-7569
Draft

fix: performance of erfinv #7568 (from dotnet/machinelearning#7569)#51
Copilot wants to merge 1 commit into
mainfrom
copilot/copy-changes-from-pr-7569

Conversation

Copilot AI commented Apr 7, 2026

Copy link
Copy Markdown

Summary

Copies the changes from dotnet#7569 (by @JeWaVe) into this fork.

Fixes: dotnet#7568

Changes

Before: An array of 1000 doubles is allocated and computed for each Erfinv call.

Now: Lazy allocation for coefficients in a readonly struct with a static constructor. Allocation and computation is done only once, the first time Erfinv is invoked.

Changed file

  • src/Microsoft.ML.CpuMath/ProbabilityFunctions.cs — Moved the series coefficient computation into a new ErfInvSeriesCoefficients struct with a static constructor, so the coefficients are computed once and reused across all calls to Erfinv.

@JanKrivanek

Copy link
Copy Markdown
Owner

/add-tests

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

Add Tests for PR Changes failed. Please review the logs for details.

@JanKrivanek

Copy link
Copy Markdown
Owner

/add-tests

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

Add Tests for PR Changes failed. Please review the logs for details.

@JanKrivanek

Copy link
Copy Markdown
Owner

/add-tests

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

Add Tests for PR Changes completed successfully!

@github-actions

github-actions Bot commented Apr 7, 2026

Copy link
Copy Markdown

Pull request created: #53

Generated by Add Tests for PR Changes

@JanKrivanek

Copy link
Copy Markdown
Owner

/add-tests

@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

Add Tests for PR Changes completed successfully!

github-actions Bot added a commit that referenced this pull request Apr 8, 2026
Add 57 unit tests covering the ProbabilityFunctions class changed in PR #51.

Tests cover:
- Erfinv boundary/special values (NaN, ±∞, 0)
- Erfinv consistency (coefficient caching returns same result)
- Erf/Erfinv round-trip accuracy
- Erf/Erfc special values and symmetry
- Erf + Erfc = 1 complement property
- Probit valid/invalid inputs

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions

github-actions Bot commented Apr 8, 2026

Copy link
Copy Markdown

Pull request created: #54

Generated by Add Tests for PR Changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

erfInv is very inneficient

2 participants