Skip to content

Commit

Permalink
Do not warn on failed return type guessing (#409)
Browse files Browse the repository at this point in the history
* Do not throw warnings

* Bump patch

* Remove redundant test case
  • Loading branch information
willtebbutt authored Dec 5, 2024
1 parent 6ec6170 commit 856f63b
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 18 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Mooncake"
uuid = "da2b9cff-9c12-43a0-ae48-6db2b0edb7d6"
authors = ["Will Tebbutt, Hong Ge, and contributors"]
version = "0.4.54"
version = "0.4.55"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
2 changes: 0 additions & 2 deletions src/interpreter/s2s_reverse_mode_ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1735,14 +1735,12 @@ _rtype(T::Type{<:DerivedRule}) = Tuple{_rtype(fieldtype(T, :fwds_oc)),fieldtype(
rule.rule = derived_rule
result = derived_rule(args...)
else
@warn "Unable to put rule in rule field. A `BadRuleTypeException` might be thrown."
err = BadRuleTypeException(rule.mi, sig, typeof(derived_rule), Trule)
result = try
derived_rule(args...)
catch
throw(err)
end
@warn "`BadRuleTypException was _not_ thrown. Expect an error at some point."
end
return result::_rtype(Trule)
end
15 changes: 0 additions & 15 deletions test/interpreter/s2s_reverse_mode_ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ struct A
end
f(a, x) = dot(a.data, x)

# Test cases designed to cause `LazyDerivedRule` to throw an error when attempting to
# construct a rule for `bar`.
foo(x) = x
@noinline bar(x) = foo(x)
baz(x) = bar(x)
Mooncake.@is_primitive Mooncake.MinimalCtx Tuple{typeof(foo),Any}
end

@testset "s2s_reverse_mode_ad" begin
Expand Down Expand Up @@ -258,15 +252,6 @@ end
rule = Mooncake.build_rrule(interp, sig; debug_mode)
@test rule isa Mooncake.rule_type(interp, sig; debug_mode)
end
@testset "LazyDerivedRule" begin
fargs = (S2SGlobals.baz, 5.0)
rule = build_rrule(fargs...)
msg = "Unable to put rule in rule field. A `BadRuleTypeException` might be thrown."
@test_logs(
(:warn, msg),
(@test_throws Mooncake.BadRuleTypeException rule(map(zero_fcodual, fargs)...)),
)
end
@testset "MooncakeRuleCompilationError" begin
@test_throws(Mooncake.MooncakeRuleCompilationError, Mooncake.build_rrule(sin))
end
Expand Down

2 comments on commit 856f63b

@willtebbutt
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request created: JuliaRegistries/General/120719

Tip: Release Notes

Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.

@JuliaRegistrator register

Release notes:

## Breaking changes

- blah

To add them here just re-invoke and the PR will be updated.

Tagging

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.4.55 -m "<description of version>" 856f63baffa1f4ac27312d5fe03a5f4acf3d6624
git push origin v0.4.55

Please sign in to comment.