JuliaGaussianProcesses / KernelFunctions.jl

Julia package for kernel functions for machine learning
https://juliagaussianprocesses.github.io/KernelFunctions.jl/stable/
MIT License
267 stars 32 forks source link

Optimize `pairwise` for `Sinus` and scalar inputs #538

Open simsurace opened 9 months ago

simsurace commented 9 months ago

Summary A call like kernelmatrix(PeriodicKernel(), rand(1000)) produces a number of allocations of the same order as the size of the kernel matrix because Sinus has a vector parameter and the dispatch hits a path which allocates that for each element of the kernel matrix.

Proposed changes We add two specialized methods that use broadcast.

What alternatives have you considered? None.

codecov[bot] commented 9 months ago

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (9a2f7bb) 72.78% compared to head (f990586) 66.57%.

Files Patch % Lines
src/distances/sinus.jl 0.00% 9 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #538 +/- ## ========================================== - Coverage 72.78% 66.57% -6.22% ========================================== Files 52 52 Lines 1374 1382 +8 ========================================== - Hits 1000 920 -80 - Misses 374 462 +88 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.