Enzyme.jl
Enzyme.jl copied to clipboard
Union leads to broken function
julia> f(cond, x) = cond ? x : 0
f (generic function with 1 method)
julia> using Enzyme
julia> autodiff(f, Active, true, Active(1.0))
ERROR: LLVM error: broken function
Stacktrace:
[1] verify
@ ~/.julia/packages/LLVM/vQ98J/src/analysis.jl:18 [inlined]
[2] lower_convention(functy::Type, mod::LLVM.Module, entry_f::LLVM.Function, actualRetType::Type)
@ Enzyme.Compiler ~/src/Enzyme/src/compiler.jl:2903
[3] codegen(output::Symbol, job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams, GPUCompiler.FunctionSpec{typeof(f), Tuple{Bool, Float64}}}; libraries::Bool, deferred_codegen::Bool, optimize::Bool, strip::Bool, validate::Bool, only_entry::Bool, parent_job::Nothing)
@ Enzyme.Compiler ~/src/Enzyme/src/compiler.jl:3103
[4] _thunk(job::GPUCompiler.CompilerJob{Enzyme.Compiler.EnzymeTarget, Enzyme.Compiler.EnzymeCompilerParams, GPUCompiler.FunctionSpec{typeof(f), Tuple{Bool, Float64}}})
@ Enzyme.Compiler ~/src/Enzyme/src/compiler.jl:3473
[5] cached_compilation(cache::Dict{UInt64, Any}, job::GPUCompiler.CompilerJob, compiler::typeof(Enzyme.Compiler._thunk), linker::typeof(Enzyme.Compiler._link))
@ GPUCompiler ~/.julia/packages/GPUCompiler/yCkO8/src/cache.jl:90
[6] thunk(f::typeof(f), df::Nothing, ::Type{Active}, tt::Type{Tuple{Const{Bool}, Active{Float64}}}, ::Val{Enzyme.API.DEM_ReverseModeCombined})
@ Enzyme.Compiler ~/src/Enzyme/src/compiler.jl:3526
[7] autodiff(::typeof(f), ::Type{Active}, ::Bool, ::Vararg{Any})
@ Enzyme ~/src/Enzyme/src/Enzyme.jl:196
[8] top-level scope
@ REPL[3]:1