You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/errors.jl
+91-12Lines changed: 91 additions & 12 deletions
Original file line number
Diff line number
Diff line change
@@ -291,18 +291,74 @@ function InteractiveUtils.code_typed(ece::EnzymeRuntimeActivityError; interactiv
291
291
end
292
292
end
293
293
294
-
295
-
struct EnzymeNoTypeError <:EnzymeError
294
+
struct EnzymeNoTypeError{MT,WT} <:EnzymeError
296
295
msg::Cstring
296
+
mi::MT
297
+
world::WT
297
298
end
298
299
299
300
function Base.showerror(io::IO, ece::EnzymeNoTypeError)
300
301
ifisdefined(Base.Experimental, :show_error_hints)
301
302
Base.Experimental.show_error_hints(io, ece)
302
303
end
303
-
print(io, "Enzyme cannot deduce type\n")
304
-
msg = Base.unsafe_string(ece.msg)
305
-
print(io, msg, '\n')
304
+
print(io, "Enzyme cannot statically prove the type of a value being differentiated and risks a correctness error if it gets it wrong.\n")
305
+
print(io, " Generally this shouldn't occur as Enzyme records type information from julia, but may be expected if you, for example copy untyped data.\n")
306
+
print(io, " or alternatively emit very large sized registers that exceed the maximum size of Enzyme's type analysis. If it seems reasonable to differentiate\n")
307
+
print(io, " this code, open an issue! If the cause of the error is too large of a register, you can request Enzyme increase the size (https://enzyme.mit.edu/julia/dev/api/#Enzyme.API.maxtypeoffset!-Tuple{Any})\n")
308
+
print(io, " or depth (https://enzyme.mit.edu/julia/dev/api/#Enzyme.API.maxtypedepth!-Tuple{Any}) of its type analysis.\n");
309
+
print(io, " Alternatively, you can tell Enzyme to take its best guess from context with (https://enzyme.mit.edu/julia/dev/api/#Enzyme.API.looseTypeAnalysis!-Tuple{Any})\n")
310
+
print(io, " All of these settings are global configurations that need to be set immeidately after loading Enzyme, before any differentiation occurs\n")
311
+
print(io, " To toggle more information for debugging (needed for bug reports), set Enzyme.Compiler.VERBOSE_ERRORS[] = true (default false)\n")
312
+
if VERBOSE_ERRORS[]
313
+
msg = Base.unsafe_string(ece.msg)
314
+
print(io, msg, '\n')
315
+
end
316
+
if ece.mi !==nothing
317
+
print(io, " Failure within method: ", ece.mi, "\n")
318
+
printstyled(io, "Hint"; bold =true, color =:cyan)
319
+
printstyled(
320
+
io,
321
+
": catch this exception as `err` and call `code_typed(err)` to inspect the errornous code.\nIf you have Cthulu.jl loaded you can also use `code_typed(err; interactive = true)` to interactively introspect the code.\n";
322
+
color =:cyan,
323
+
)
324
+
end
325
+
end
326
+
327
+
function InteractiveUtils.code_typed(ece::EnzymeNoTypeError; interactive::Bool=false, kwargs...)
328
+
mi = ece.mi
329
+
if mi ===nothing
330
+
throw(AssertionError("code_typed(::EnzymeNoTypeError; interactive::Bool=false, kwargs...) not supported for error without mi"))
0 commit comments