function prod2(xs::Vector)
p = one(eltype(xs))
for x in xs
p = p * x
p == 0 && break # exit early once you know the answer
end
p
end
ChainRulesCore.@non_differentiable eltype(::Any)
function main()
x = rand(3)
Yota.grad(prod2, x)
_, tape = trace(prod2, x; ctx=GradCtx())
end
From https://github.com/FluxML/NNlib.jl/pull/434#issuecomment-1235674312