@@ -27,6 +27,13 @@ struct ∂☆new{N}; end
27
27
function ∂☆nomethd (@nospecialize (args))
28
28
throw (MethodError (primal (args[1 ]), map (primal, Base. tail (args))))
29
29
end
30
+ function ∂☆builtin ((f_bundle, args... ))
31
+ f = primal (f_bundle)
32
+ argtypes = Any[Core. Typeof (primal (arg)) for arg in args]
33
+ tt = Base. signature_type (f, argtypes)
34
+ sig = Base. sprint (Base. show_tuple_as_call, Symbol (" " ), tt)
35
+ throw (DomainError (f, " No `ChainRulesCore.frule` found for the built-in function `$sig `" ))
36
+ end
30
37
31
38
function perform_fwd_transform (world:: UInt , source:: LineNumberNode ,
32
39
@nospecialize (ff:: Type{∂☆recurse{N}} ), @nospecialize (args)) where {N}
@@ -36,6 +43,11 @@ function perform_fwd_transform(world::UInt, source::LineNumberNode,
36
43
end
37
44
38
45
sig = Tuple{map (π, args)... }
46
+ if sig. parameters[1 ] <: Core.Builtin
47
+ return generate_lambda_ex (world, source,
48
+ Core. svec (:ff , :args ), Core. svec (), :(∂☆builtin (args)))
49
+ end
50
+
39
51
mthds = Base. _methods_by_ftype (sig, - 1 , world)
40
52
if mthds === nothing || length (mthds) != 1
41
53
# Core.println("[perform_fwd_transform] ", sig, " => ", mthds)
0 commit comments