Skip to content

Pass keyword arguments to test_approx when checking thunks #247

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

Merged
merged 3 commits into from
May 23, 2022
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ChainRulesTestUtils"
uuid = "cdddcdb0-9152-4a09-a978-84456f9df70a"
version = "1.7.0"
version = "1.7.1"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand Down
2 changes: 1 addition & 1 deletion src/testers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ function test_rrule(
end

if check_thunked_output_tangent
test_approx(ad_cotangents, pullback(@thunk(ȳ)), "pulling back a thunk:")
test_approx(ad_cotangents, pullback(@thunk(ȳ)), "pulling back a thunk:"; isapprox_kwargs...)
check_inferred && _test_inferred(pullback, @thunk(ȳ))
end
end # top-level testset
Expand Down
5 changes: 4 additions & 1 deletion test/testers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,10 @@ end
function ChainRulesCore.rrule(::typeof(my_id), x)
my_id_pb(ȳ) = (NoTangent(), ȳ)
function my_id_pb(ȳ::AbstractThunk)
precision = rand() > 0.5 ? Float64 : Float32
# We use a condition that always evaluates to true to avoid issues with tolerances
# (see https://github.com/JuliaDiff/ChainRulesTestUtils.jl/pull/247)
# The function is type unstable for `Float64` inputs nevertheless
precision = rand() >= 0.0 ? Float64 : Float32
return (NoTangent(), precision(unthunk(ȳ)))
end
return x, my_id_pb
Expand Down