Skip to content

Commit

Permalink
Improve safe mode options (#149)
Browse files Browse the repository at this point in the history
* Bump patch version

* More safe mode options
  • Loading branch information
willtebbutt authored May 14, 2024
1 parent abc0b23 commit 5872a96
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Tapir"
uuid = "07d77754-e150-4737-8c94-cd238a1fb45b"
authors = ["Will Tebbutt, Hong Ge, and contributors"]
version = "0.2.9"
version = "0.2.10"

[deps]
ADTypes = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
Expand Down
15 changes: 12 additions & 3 deletions src/interpreter/s2s_reverse_mode_ad.jl
Original file line number Diff line number Diff line change
Expand Up @@ -722,11 +722,13 @@ function rule_type(interp::TapirInterpreter{C}, ::Type{sig}) where {C, sig}
end

"""
build_rrule(args...)
build_rrule(args...; safety_on=false)
Helper method. Only uses static information from `args`.
"""
build_rrule(args...) = build_rrule(PInterp(), _typeof(TestUtils.__get_primals(args)))
function build_rrule(args...; safety_on=false)
return build_rrule(PInterp(), _typeof(TestUtils.__get_primals(args)); safety_on)
end

"""
build_rrule(interp::PInterp{C}, sig::Type{<:Tuple}; safety_on=false) where {C}
Expand All @@ -736,7 +738,14 @@ for `rrule!!` for more info.
If `safety_on` is `true`, then all calls to rules are replaced with calls to `SafeRRule`s.
"""
function build_rrule(interp::PInterp{C}, sig::Type{<:Tuple}; safety_on=false) where {C}
function build_rrule(
interp::PInterp{C}, sig::Type{<:Tuple}; safety_on=false, silence_safety_messages=true
) where {C}

# If we're compiling in safe mode, let the user know by default.
if !silence_safety_messages
@info "Compiling rule for $sig in safe mode. Disable for best performance."
end

# Reset id count. This ensures that the IDs generated are the same each time this
# function runs.
Expand Down

2 comments on commit 5872a96

@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/106745

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.2.10 -m "<description of version>" 5872a968ec565b1d1bdd26015ee0cb7230a0c818
git push origin v0.2.10

Please sign in to comment.