Skip to content

Commit

Permalink
Document CheckNaN
Browse files Browse the repository at this point in the history
  • Loading branch information
danielwe committed Feb 16, 2025
1 parent 4a5316e commit 0b4fee5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
6 changes: 5 additions & 1 deletion docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Types and constants

```@index
Modules = [Enzyme, EnzymeCore, EnzymeCore.EnzymeRules, EnzymeTestUtils, Enzyme.API]
Modules = [Enzyme, EnzymeCore, EnzymeCore.EnzymeRules, EnzymeTestUtils, Enzyme.API, Enzyme.Compiler]
Order = [:type, :constant]
```

Expand All @@ -20,3 +20,7 @@ Order = [:macro, :function]
Modules = [Enzyme, EnzymeCore, EnzymeCore.EnzymeRules, EnzymeTestUtils, Enzyme.API]
Order = [:module, :type, :constant, :macro, :function]
```

```@docs
Enzyme.Compiler.CheckNan
```
1 change: 1 addition & 0 deletions docs/src/internal_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
```@autodocs
Modules = [Enzyme.Compiler]
Order = [:module, :type, :constant, :macro, :function]
Filter = t -> !(t === Enzyme.Compiler.CheckNan)
```
8 changes: 8 additions & 0 deletions src/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,15 @@ function removed_ret_parms(F::LLVM.Function)
return retRemove, parmsRemoved
end

"""
CheckNan::Ref{Bool}
If `Enzyme.Compiler.CheckNan[] == true`, Enzyme will error at the first encounter of a `NaN`
during differentiation. Useful as a debugging tool to help locate the call whose derivative
is the source of unexpected `NaN`s. Off by default.
"""
const CheckNan = Ref(false)

function julia_sanitize(
orig::LLVM.API.LLVMValueRef,
val::LLVM.API.LLVMValueRef,
Expand Down

0 comments on commit 0b4fee5

Please sign in to comment.