Skip to content

Commit 52a91fe

Browse files
committed
Clearer message
1 parent d53d943 commit 52a91fe

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

  • DifferentiationInterface/ext/DifferentiationInterfaceEnzymeExt

DifferentiationInterface/ext/DifferentiationInterfaceEnzymeExt/init.jl

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
const HINT_END = "\n\nThis hint appears because DifferentiationInterface and Enzyme are both loaded. It does not necessarily imply that Enzyme is being called through DifferentiationInterface.\n\n"
2+
3+
function HINT_START(option)
4+
return "\nIf you are using Enzyme by selecting the `AutoEnzyme` object from ADTypes, you may want to try setting the `$option` option as follows:"
5+
end
6+
17
function __init__()
28
# robust against internal changes
39
condition = (
@@ -14,29 +20,23 @@ function __init__()
1420
# robust against internal changes
1521
Base.Experimental.register_error_hint(T) do io, exc
1622
if occursin("EnzymeMutabilityException", string(nameof(T)))
23+
printstyled(io, HINT_START("function_annotation"); bold=true)
1724
printstyled(
1825
io,
19-
"\nIf you are using Enzyme through DifferentiationInterface, you may want to try modifying the ADTypes backend object as follows:";
20-
bold=true,
21-
)
22-
printstyled(
23-
io,
24-
"\n\n\tAutoEnzyme(; function_annotation=Enzyme.Duplicated)\n\n";
26+
"\n\n\tAutoEnzyme(; function_annotation=Enzyme.Duplicated)";
2527
color=:cyan,
2628
bold=true,
2729
)
30+
printstyled(io, HINT_END; italic=true)
2831
elseif occursin("EnzymeRuntimeActivityError", string(nameof(T)))
32+
printstyled(io, HINT_START("mode"); bold=true)
2933
printstyled(
3034
io,
31-
"\nIf you are using Enzyme through DifferentiationInterface, you may want to try modifying the ADTypes backend object as follows:";
32-
bold=true,
33-
)
34-
printstyled(
35-
io,
36-
"\n\n\tAutoEnzyme(; mode=Enzyme.set_runtime_activity(Enzyme.Forward))\n\tAutoEnzyme(; mode=Enzyme.set_runtime_activity(Enzyme.Reverse))\n\n";
35+
"\n\n\tAutoEnzyme(; mode=Enzyme.set_runtime_activity(Enzyme.Forward))\n\tAutoEnzyme(; mode=Enzyme.set_runtime_activity(Enzyme.Reverse))";
3736
color=:cyan,
3837
bold=true,
3938
)
39+
printstyled(io, HINT_END; italic=true)
4040
end
4141
end
4242
end

0 commit comments

Comments
 (0)