Skip to content

Commit 3d4e912

Browse files
willtebbuttgdalle
andauthored
Add safe mode (#55)
* Add safe mode * Add test to check that safe mode is on by default * Bump minor version * Update test/dense.jl --------- Co-authored-by: Guillaume Dalle <[email protected]>
1 parent d749b5a commit 3d4e912

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uuid = "47edcb42-4c32-4615-8424-f2b9edc5f35b"
33
authors = [
44
"Vaibhav Dixit <[email protected]>, Guillaume Dalle and contributors",
55
]
6-
version = "1.1.0"
6+
version = "1.2.0"
77

88
[deps]
99
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/dense.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,8 +172,14 @@ mode(::AutoSymbolics) = SymbolicMode()
172172
Struct used to select the [Tapir.jl](https://github.com/withbayes/Tapir.jl) backend for automatic differentiation.
173173
174174
Exported from [ADTypes.jl](https://github.com/SciML/ADTypes.jl).
175+
176+
# Keyword Arguments
177+
178+
- `safe_mode::Bool`: whether to run additional checks to catch errors early. On by default. Turn off to maximise performance if your code runs correctly.
175179
"""
176-
struct AutoTapir <: AbstractADType end
180+
Base.@kwdef struct AutoTapir <: AbstractADType
181+
safe_mode::Bool = true
182+
end
177183

178184
mode(::AutoTapir) = ReverseMode()
179185

test/dense.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ end
138138
@test ad isa AbstractADType
139139
@test ad isa AutoTapir
140140
@test mode(ad) isa ReverseMode
141+
@test ad.safe_mode
142+
143+
ad = AutoTapir(; safe_mode=false)
144+
@test !ad.safe_mode
141145
end
142146

143147
@testset "AutoTracker" begin

0 commit comments

Comments
 (0)