Skip to content

Commit

Permalink
Add verbose error message toggle
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Dec 5, 2024
1 parent 6606cd9 commit e8f4d15
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/errors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@ struct IllegalTypeAnalysisException <: CompilationException
bt::Union{Nothing,Vector{StackTraces.StackFrame}}
end

const VERBOSE_ERRORS = Ref(false)
function Base.showerror(io::IO, ece::IllegalTypeAnalysisException)
print(io, "Enzyme compilation failed due to illegal type analysis.\n")
if ece.ir !== nothing
print(io, "Current scope: \n")
print(io, ece.ir)
print(io, " This usually indicates the use of a Union type, which is not fully supported with Enzyme.API.strictAliasing set to true [the default].\n")
print(io, " Ideally, remove the union (which will also make your code faster), or try setting Enzyme.API.strictAliasing!(false) before any autodiff call.\n")
print(io, " To toggle more information for debugging (needed for bug reports), set Enzyme.Compiler.VERBOSE_ERRORS[] = true (default false)\n")
if VERBOSE_ERRORS[]
if ece.ir !== nothing
print(io, "Current scope: \n")
print(io, ece.ir)
end
print(io, "\n Type analysis state: \n")
write(io, ece.sval)
print(io, '\n', ece.msg, '\n')
end
print(io, "\n Type analysis state: \n")
write(io, ece.sval)
print(io, '\n', ece.msg, '\n')
if ece.bt !== nothing
print(io, "\nCaused by:")
Base.show_backtrace(io, ece.bt)
Expand Down

0 comments on commit e8f4d15

Please sign in to comment.