Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add verbose error message toggle #2173

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading