Open
Description
julia> module MWE
using DifferentiationInterface, Mooncake
function f(x)
arr = Vector{Float64}(undef, Threads.nthreads())
Threads.@threads for i in eachindex(arr)
arr[i] = x
end
return sum(arr)
end
value_and_gradient(f, AutoMooncake(; config=nothing), 2.0)
end
WARNING: replacing module MWE.
ERROR: No rrule!! available for foreigncall with primal argument types Tuple{Val{:jl_enter_threaded_region}, Val{Nothing}, Tuple{}, Val{0}, Val{:ccall}}. This problem has most likely arisen because there is a ccall somewhere in the function you are trying to differentiate, for which an rrule!! has not been explicitly written.You have three options: write an rrule!! for this foreigncall, write an rrule!! for a Julia function that calls this foreigncall, or re-write your code to avoid this foreigncall entirely. If you believe that this error has arisen for some other reason than the above, or the above does not help you to workaround this problem, please open an issue.
How difficult would it be to add support for this?