We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3ff8347 commit d057de1Copy full SHA for d057de1
test/autodiff.jl
@@ -102,6 +102,19 @@ end
102
@test res[1] ≈ ones(2, 2)
103
end
104
105
+f_sincos(x) = map(sin, x) + map(cos, reverse(x))
106
+f_sincos_jac(x) = [cos(x[i]) * (i == j ? 1 : 0) - sin(x[end-i+1]) * (i == (length(x) - j + 1) ? 1 : 0) for i in 1:length(x), j in 1:length(x)]
107
+
108
+@testset "Forward Jacobian" begin
109
+ jac(x) = only(Enzyme.jacobian(Enzyme.Forward, f_sincos, x))
110
+ x_r = Reactant.to_rarray(rand(10))
111
112
+ j_gt = f_sincos_jac(x_r)
113
+ j_reactant = Reactant.@jit jac(x_r)
114
115
+ @test j_reactant ≈ j_gt
116
+end
117
118
mutable struct StateReturn
119
st::Any
120
0 commit comments