Skip to content
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

Allocate df with similar, partially fixes GPU support #123

Merged
merged 3 commits into from
Jun 10, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/objective_types/abstract.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,15 @@ function make_fdf(x, F::Number, f, g!)
end

# Initialize an n-by-n Jacobian
alloc_DF(x, F) = fill(eltype(F)(NaN), length(F), length(x))
function alloc_DF(x, F)
a = (Base.OneTo(length(F)), Base.OneTo(length(x)))
df = similar(F, a)
fill!(df, NaN)
return df
end
# Initialize a gradient shaped like x
alloc_DF(x, F::T) where T<:Number = x_of_nans(x, promote_type(eltype(x), T))
# Initialize an n-by-n Hessian
alloc_H(x, F::T) where T<:Number = alloc_DF(x, promote_type(eltype(x), T).(x))
function alloc_H(x, F::T) where T<:Number
eltype(x)(NaN).*x*x'
end