Strange behavior of differentiating constant functions in Zygote

Why is

using Zygote: gradient
gradient((x -> 0.0), 1)

giving
(nothing, )
?

Nothing encodes zero derivative in zygote. This is chosen so that some computations can be avoided in more complex code.

1 Like