Closed wsmoses closed 1 year ago
Fails only on Julia 1.6 (succeeds on CI 1.7/8).
Haven't had time to look into this. cc: @maleadt in case it tickles a memory.
Note: Requires running on https://github.com/EnzymeAD/Enzyme.jl/pull/537
Sorry, no. dump the compile
dict to see what's in there?
Well that is odd:
compiled = Dict{Any, Any}(MethodInstance for genericsin(::Float64) => (ci = Core.CodeInstance(MethodInstance for genericsin(::Float64), #undef, 0x0000000000001c46, 0xffffffffffffffff, Any, #undef, UInt8[0x0c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x08, 0x16, 0x88, 0xc2, 0xe6, 0x1f, 0x20, 0x11, 0x04, 0x2e, 0x03, 0x01, 0x17, 0x11, 0x05, 0x38, 0xc1, 0x37, 0x03, 0x02, 0x16, 0x88, 0xc2, 0xe6, 0x11, 0x06, 0x3e, 0x3e, 0x16, 0x01, 0xc2, 0xf2, 0x00, 0x00, 0x00, 0x3d, 0x16, 0x88, 0xc5, 0x27, 0x00, 0x2f, 0x2f, 0x23, 0x11, 0x02, 0x11, 0x03, 0xc3, 0xbf, 0x2f, 0x21, 0x11, 0x00, 0x56, 0x2b, 0xc2, 0x02, 0xc0, 0x2f, 0x21, 0x11, 0x07, 0x56, 0x2b, 0xc2, 0x02, 0xc1, 0x2f, 0x21, 0x11, 0x07, 0x56, 0x2b, 0xc3, 0x02, 0xc1, 0x2f, 0x21, 0x11, 0x07, 0x56, 0x2b, 0xc4, 0x02, 0xc1, 0x2f, 0x21, 0x11, 0x07, 0x56, 0x2b, 0xc6, 0x02, 0xc1, 0x3d, 0x05, 0x05, 0x01], false, false, Ptr{Nothing} @0x0000000000000000, Ptr{Nothing} @0x0000000000000000), func = "jfptr_genericsin_1978", specfunc = "julia_genericsin_1977"))
ERROR: LoadError: KeyError: key MethodInstance for sin(::Float64) not found
using Enzyme
module Mock
import GPUCompiler
# local method table for device functions
@static if isdefined(Base.Experimental, Symbol("@overlay"))
Base.Experimental.@MethodTable(method_table)
else
const method_table = nothing
end
# list of overrides (only for Julia 1.6)
const overrides = Expr[]
macro device_override(ex)
ex = macroexpand(__module__, ex)
if Meta.isexpr(ex, :call)
@show ex = eval(ex)
error()
end
code = quote
$GPUCompiler.@override($method_table, $ex)
end
if isdefined(Base.Experimental, Symbol("@overlay"))
return esc(code)
else
push!(overrides, code)
return
end
end
@device_override Base.sin(x::Float64) = ccall("extern __nv_sin", llvmcall, Cdouble, (Cdouble,), x)
function __init__()
# register device overrides
eval(Expr(:block, overrides...))
empty!(overrides)
end
end
genericsin(x) = Base.invokelatest(sin, x)
res = Enzyme.autodiff(Forward, genericsin, BatchDuplicated(2.0, NTuple{10,Float64}((Float64(i) for i in 1:10))))[1]