ChainRulesCore.jl icon indicating copy to clipboard operation
ChainRulesCore.jl copied to clipboard

`tangent * tangent` and `dot(tangent, tangent)` can return tangents.

Open lukas-weber opened this issue 1 year ago • 0 comments

I noticed that there are methods of * and dot for the AbstractZero types that work like

Base.:*(::NoTangent, ::NoTangent) = NoTangent()
LinearAlgebra.dot(::NoTangent, ::ZeroTangent) = ZeroTangent()

However, if both arguments are tangents,

  1. * should not be defined.
  2. dot should return a real number, not another tangent.

In my understanding, code that relies on such nonlinear tangent to tangent operations cannot be correct, so it may be worthwhile to remove such methods.

lukas-weber avatar Dec 15 '23 22:12 lukas-weber