Skip to content

Commit e7f78c9

Browse files
Allocate df with similar, partially fixes GPU support (#123)
* Allocate df with similar, fixes GPU support * Change H allocator. Co-authored-by: Patrick Kofod Mogensen <[email protected]>
1 parent e147fe4 commit e7f78c9

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/objective_types/abstract.jl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,15 @@ function make_fdf(x, F::Number, f, g!)
1616
end
1717

1818
# Initialize an n-by-n Jacobian
19-
alloc_DF(x, F) = fill(eltype(F)(NaN), length(F), length(x))
19+
function alloc_DF(x, F)
20+
a = (Base.OneTo(length(F)), Base.OneTo(length(x)))
21+
df = similar(F, a)
22+
fill!(df, NaN)
23+
return df
24+
end
2025
# Initialize a gradient shaped like x
2126
alloc_DF(x, F::T) where T<:Number = x_of_nans(x, promote_type(eltype(x), T))
2227
# Initialize an n-by-n Hessian
23-
alloc_H(x, F::T) where T<:Number = alloc_DF(x, promote_type(eltype(x), T).(x))
28+
function alloc_H(x, F::T) where T<:Number
29+
eltype(x)(NaN).*x*x'
30+
end

0 commit comments

Comments
 (0)