Skip to content

Commit 1c32181

Browse files
authored
relax restriction of x::AbstractVector in threaded_gradient!
1 parent a72e010 commit 1c32181

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/PolyesterForwardDiff.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ function evaluate_chunks!(f::F, (r,Δx,x), start, stop, ::ForwardDiff.Chunk{C},
4949
end
5050
end
5151

52-
function threaded_gradient!(f::F, Δx::AbstractVector, x::AbstractVector, ::ForwardDiff.Chunk{C}, check = Val{false}()) where {F,C}
52+
function threaded_gradient!(f::F, Δx::AbstractArray, x::AbstractArray, ::ForwardDiff.Chunk{C}, check = Val{false}()) where {F,C}
5353
N = length(x)
5454
d = cld_fast(N, C)
5555
r = Ref{eltype(Δx)}()

test/runtests.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,12 @@ ForwardDiff.jacobian!(dxref, g!, yref, x, ForwardDiff.JacobianConfig(g!, yref, x
3737
PolyesterForwardDiff.threaded_jacobian!(g!, y, dx, x, ForwardDiff.Chunk(8),Val{true}());
3838
@test dx dxref
3939
@test y yref
40+
41+
42+
X = randn(10,80);
43+
dXref = similar(x);
44+
dX = similar(x);
45+
ForwardDiff.gradient!(dXref, f, X, ForwardDiff.GradientConfig(f, x, ForwardDiff.Chunk(8), nothing));
46+
PolyesterForwardDiff.threaded_gradient!(f, dX, X, ForwardDiff.Chunk(8));
47+
48+
@test dX dXref

0 commit comments

Comments
 (0)