We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 730ea67 commit 9918900Copy full SHA for 9918900
src/extra_rules.jl
@@ -291,4 +291,12 @@ end
291
# https://github.com/JuliaDiff/ChainRulesCore.jl/issues/607
292
Base.:(==)(x::Number, ::ZeroTangent) = iszero(x)
293
Base.:(==)(::ZeroTangent, x::Number) = iszero(x)
294
-Base.hash(x::ZeroTangent, h::UInt64) = hash(0, h)
+Base.hash(x::ZeroTangent, h::UInt64) = hash(0, h)
295
+
296
+# should this be in ChainRules/ChainRulesCore?
297
+# Avoid making nested backings, a Tangent is already a valid Tangent for a Tangent,
298
+# or a valid second order Tangent for the primal
299
+function frule((_, ẋ), T::Type{<:Tangent}, x)
300
+ ẋ::Tangent
301
+ return T(x), ẋ
302
+end
0 commit comments