Skip to content

Commit abfa999

Browse files
committed
attempt to stabilize some AD tests
1 parent be62976 commit abfa999

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

test/autodiff/ad.jl

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -303,22 +303,26 @@ for V in spacelist
303303
end
304304

305305
@timedtestset "Linear Algebra part II with scalartype $T" for T in eltypes
306+
atol = precision(T)
307+
rtol = precision(T)
306308
for i in 1:3
307309
E = randn(T, (V[1:i]...) (V[1:i]...))
308-
test_rrule(LinearAlgebra.tr, E)
309-
test_rrule(exp, E; check_inferred = false)
310-
test_rrule(inv, E)
310+
test_rrule(LinearAlgebra.tr, E; atol, rtol)
311+
test_rrule(exp, E; check_inferred = false, atol, rtol)
312+
test_rrule(inv, E; atol, rtol)
311313
end
312314

313315
A = randn(T, V[1] V[2] V[3] V[4] V[5])
314-
test_rrule(LinearAlgebra.adjoint, A)
315-
test_rrule(LinearAlgebra.norm, A, 2)
316+
test_rrule(LinearAlgebra.adjoint, A; atol, rtol)
317+
test_rrule(LinearAlgebra.norm, A, 2; atol, rtol)
316318

317319
B = randn(T, space(A))
318-
test_rrule(LinearAlgebra.dot, A, B)
320+
test_rrule(LinearAlgebra.dot, A, B; atol, rtol)
319321
end
320322

321323
@timedtestset "Matrix functions ($T)" for T in eltypes
324+
atol = precision(T)
325+
rtol = precision(T)
322326
for f in (sqrt, exp)
323327
check_inferred = false # !(T <: Real) # not type-stable for real functions
324328
t1 = randn(T, V[1] V[1])
@@ -340,9 +344,9 @@ for V in spacelist
340344
randn!(d3.data)
341345
end
342346

343-
test_rrule(f, t1; rrule_f = Zygote.rrule_via_ad, check_inferred)
344-
test_rrule(f, t2; rrule_f = Zygote.rrule_via_ad, check_inferred)
345-
test_rrule(f, d d2; check_inferred, output_tangent = d3)
347+
test_rrule(f, t1; rrule_f = Zygote.rrule_via_ad, check_inferred, atol, rtol)
348+
test_rrule(f, t2; rrule_f = Zygote.rrule_via_ad, check_inferred, atol, rtol)
349+
test_rrule(f, d d2; check_inferred, output_tangent = d3, atol, rtol)
346350
end
347351
end
348352

0 commit comments

Comments
 (0)