Skip to content

Commit 0b4fee5

Browse files
committed
Document CheckNaN
1 parent 4a5316e commit 0b4fee5

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

docs/src/api.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
## Types and constants
44

55
```@index
6-
Modules = [Enzyme, EnzymeCore, EnzymeCore.EnzymeRules, EnzymeTestUtils, Enzyme.API]
6+
Modules = [Enzyme, EnzymeCore, EnzymeCore.EnzymeRules, EnzymeTestUtils, Enzyme.API, Enzyme.Compiler]
77
Order = [:type, :constant]
88
```
99

@@ -20,3 +20,7 @@ Order = [:macro, :function]
2020
Modules = [Enzyme, EnzymeCore, EnzymeCore.EnzymeRules, EnzymeTestUtils, Enzyme.API]
2121
Order = [:module, :type, :constant, :macro, :function]
2222
```
23+
24+
```@docs
25+
Enzyme.Compiler.CheckNan
26+
```

docs/src/internal_api.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99
```@autodocs
1010
Modules = [Enzyme.Compiler]
1111
Order = [:module, :type, :constant, :macro, :function]
12+
Filter = t -> !(t === Enzyme.Compiler.CheckNan)
1213
```

src/compiler.jl

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,15 @@ function removed_ret_parms(F::LLVM.Function)
437437
return retRemove, parmsRemoved
438438
end
439439

440+
"""
441+
CheckNan::Ref{Bool}
442+
443+
If `Enzyme.Compiler.CheckNan[] == true`, Enzyme will error at the first encounter of a `NaN`
444+
during differentiation. Useful as a debugging tool to help locate the call whose derivative
445+
is the source of unexpected `NaN`s. Off by default.
446+
"""
440447
const CheckNan = Ref(false)
448+
441449
function julia_sanitize(
442450
orig::LLVM.API.LLVMValueRef,
443451
val::LLVM.API.LLVMValueRef,

0 commit comments

Comments
 (0)