-
Notifications
You must be signed in to change notification settings - Fork 40
[WIP] Use Tullio for pairwise distances #385
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
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
888d752
Correction of the docstring
theogf a8f1183
Merge branch 'master' into tg/correct_doc_spectral_mixture
st-- 31adb2b
Fixes documentations
theogf 966a726
Merge remote-tracking branch 'origin/tg/correct_doc_spectral_mixture'…
theogf f721a58
Merge branch 'master' into tg/correct_doc_spectral_mixture
theogf 7cb39d3
Merge branch 'master' into tg/correct_doc_spectral_mixture
theogf ca3a76c
Merge branch 'tg/correct_doc_spectral_mixture' of github.com:JuliaGau…
theogf de1c84a
Fix multiple docs
theogf 50d5471
Version to test
theogf e86f572
Wrote more detailed tests
theogf 01cfaaf
Add a bunch of cdot
theogf ffba539
changed spectral_mixture_kernel to a struct
theogf cb27209
formatting
theogf 4f5c025
revert change lineartransform
theogf 5f8e7f5
Add functor
theogf 911cb73
Update the docs
theogf 64e3641
Update docs
theogf 6f9cae8
Update src/basekernels/sm.jl
theogf 6fde691
Fixed docstrings and added constructors checks
theogf 27db614
Merge branch 'master' into tg/correct_doc_spectral_mixture
theogf 38f9eed
Update src/basekernels/sm.jl
theogf a07704b
Fix checks
theogf f37b566
improve computations using broadcaster
theogf 1b1ea99
Introduction of Tullio to perform pairwise operations
theogf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
@deprecate spectral_mixture_kernel SpectralMixtureKernel |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,22 @@ | ||
## DotProduct is not following the PreMetric rules since d(x, x) != 0 and d(x, y) >= 0 for all x, y | ||
struct DotProduct <: Distances.UnionPreMetric end | ||
struct DotProduct <: AbstractBinaryOp end | ||
|
||
@inline function Distances._evaluate(::DotProduct, a::AbstractVector, b::AbstractVector) | ||
@boundscheck if length(a) != length(b) | ||
throw( | ||
DimensionMismatch( | ||
"first array has length $(length(a)) which does not match the length of the second, $(length(b)).", | ||
), | ||
) | ||
end | ||
return dot(a, b) | ||
(::DotProduct)(a::AbstractVector, b::AbstractVector) = dot(a, b) | ||
|
||
(::DotProduct)(a::Number, b::Number) = a * b | ||
|
||
function pairwise(::DotProduct, x::ColVecs, y::ColVecs) | ||
return @tullio out[i, j] := x.X[k, i] * y.X[k, j] | ||
end | ||
|
||
Distances.result_type(::DotProduct, Ta::Type, Tb::Type) = promote_type(Ta, Tb) | ||
function pairwise(::DotProduct, x::RowVecs, y::RowVecs) | ||
return @tullio out[i, j] := x.X[i, k] * y.X[j, k] | ||
end | ||
|
||
@inline Distances.eval_op(::DotProduct, a::Real, b::Real) = a * b | ||
@inline function (dist::DotProduct)(a::AbstractArray, b::AbstractArray) | ||
return Distances._evaluate(dist, a, b) | ||
function colwise(::DotProduct, x::RowVecs, y::RowVecs=x) | ||
return @tullio out[i] := x.X[i, k] * y.X[i, k] | ||
end | ||
@inline (dist::DotProduct)(a::Number, b::Number) = a * b | ||
|
||
function colwise(::DotProduct, x::ColVecs, y::ColVecs=x) | ||
return @tullio out[i] := x.X[k, i] * y.X[k, i] | ||
end | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[JuliaFormatter] reported by reviewdog 🐶