Skip to content

Commit

Permalink
return lazy Fill arrays for mean functions from #197
Browse files Browse the repository at this point in the history
  • Loading branch information
st-- committed Oct 28, 2021
1 parent a521ae5 commit becacaa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/mean_function.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ struct ZeroMean{T<:Real} <: MeanFunction end
"""
This is an AbstractGPs-internal workaround for AD issues; ideally we would just extend Base.map
"""
_map_meanfunction(::ZeroMean{T}, x::AbstractVector) where {T} = zeros(T, length(x))
_map_meanfunction(::ZeroMean{T}, x::AbstractVector) where {T} = Zeros{T}(length(x))

function ChainRulesCore.rrule(::typeof(_map_meanfunction), m::ZeroMean, x::AbstractVector)
map_ZeroMean_pullback(Δ) = (NoTangent(), NoTangent(), ZeroTangent())
Expand All @@ -28,7 +28,7 @@ struct ConstMean{T<:Real} <: MeanFunction
c::T
end

_map_meanfunction(m::ConstMean, x::AbstractVector) = fill(m.c, length(x))
_map_meanfunction(m::ConstMean, x::AbstractVector) = Fill(m.c, length(x))

"""
CustomMean{Tf} <: MeanFunction
Expand Down

0 comments on commit becacaa

Please sign in to comment.