Skip to content

Commit

Permalink
Patch AD performance bug (#272)
Browse files Browse the repository at this point in the history
* Replace Base.Fix1 with regular closure

* Bump patch
  • Loading branch information
willtebbutt authored Mar 29, 2021
1 parent 13985cc commit 55f4909
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "KernelFunctions"
uuid = "ec8451be-7e33-11e9-00cf-bbf324bd1392"
version = "0.9.0"
version = "0.9.1"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
12 changes: 6 additions & 6 deletions src/matrix/kernelmatrix.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,32 +80,32 @@ kernelmatrix_diag(κ::Kernel, x::AbstractVector, y::AbstractVector) = map(κ, x,
function kernelmatrix!(K::AbstractMatrix, κ::SimpleKernel, x::AbstractVector)
validate_inplace_dims(K, x)
pairwise!(K, metric(κ), x)
return map!(Base.Fix1(kappa, κ), K, K)
return map!(x -> kappa(κ, x), K, K)
end

function kernelmatrix!(
K::AbstractMatrix, κ::SimpleKernel, x::AbstractVector, y::AbstractVector
)
validate_inplace_dims(K, x, y)
pairwise!(K, metric(κ), x, y)
return map!(Base.Fix1(kappa, κ), K, K)
return map!(x -> kappa(κ, x), K, K)
end

function kernelmatrix::SimpleKernel, x::AbstractVector)
return map(Base.Fix1(kappa, κ), pairwise(metric(κ), x))
return map(x -> kappa(κ, x), pairwise(metric(κ), x))
end

function kernelmatrix::SimpleKernel, x::AbstractVector, y::AbstractVector)
validate_inputs(x, y)
return map(Base.Fix1(kappa, κ), pairwise(metric(κ), x, y))
return map(x -> kappa(κ, x), pairwise(metric(κ), x, y))
end

function kernelmatrix_diag::SimpleKernel, x::AbstractVector)
return map(Base.Fix1(kappa, κ), colwise(metric(κ), x))
return map(x -> kappa(κ, x), colwise(metric(κ), x))
end

function kernelmatrix_diag::SimpleKernel, x::AbstractVector, y::AbstractVector)
return map(Base.Fix1(kappa, κ), colwise(metric(κ), x, y))
return map(x -> kappa(κ, x), colwise(metric(κ), x, y))
end

#
Expand Down

2 comments on commit 55f4909

@willtebbutt
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request created: JuliaRegistries/General/33083

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.1 -m "<description of version>" 55f49096e4da64f26d5f5f9317d15f8044c4ad39
git push origin v0.9.1

Please sign in to comment.