Skip to content

Use Iterators.peel, reduce allocations, and add missing kernelmatrix_diag! definitions + tests #379

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

Merged
merged 6 commits into from
Oct 8, 2021

Conversation

devmotion
Copy link
Member

@devmotion devmotion commented Oct 8, 2021

This PR started with a small improvement (replace first + Iterators.drop with Iterators.peel) but lead to some more changes in the end 😄 So taken together, this PR

  • replaces first + Iterators.drop with Iterators.peel
  • reduces allocations in kernelmatrix! and kernelmatrix_diag! functions of KernelTensorProduct for > 2 kernels (allocations are the same for 2 kernels and are increased for 1 kernel, but in the latter case one should not construct a KernelTensorProduct in the first place)
  • adds a missing definition of the binary kernelmatrix_diag! for KernelTensorProduct and a test for it to test_interface
  • adds a missing definition of the binary kernelmatrix_diag! for ScaledKernel (a quick check revealed it was missing, maybe more kernels have to be fixed for tests to pass)

@theogf
Copy link
Member

theogf commented Oct 8, 2021

I did not know about peel it's very nice! LGTM if all tests pass


function validate_inplace_dims(K::AbstractVector, x::AbstractVector)
if length(K) != length(x)
function validate_inplace_dims(K::AbstractVector, x::AbstractVector, y::AbstractVector)
Copy link
Member Author

Choose a reason for hiding this comment

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

The version for two inputs was missing

@devmotion devmotion merged commit f5bcae4 into master Oct 8, 2021
@devmotion devmotion deleted the dw/peel branch October 8, 2021 13:34
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.

2 participants