Skip to content

TrackedVector' * v is ambiguous for AbstractVectors other than Vector #310

Open

Description

@devmotion

The product of an adjoint or transposed TrackedVector with an untracked AbstractVector is ambiguous unless the right operand is one of ARRAY_TYPES (e.g. a Vector):

using ReverseDiff, StaticArrays
ReverseDiff.gradient(u -> u' * SVector(1.0, 2.0), rand(2))  # MethodError: ... is ambiguous
ReverseDiff.gradient(u -> u' * (1:2), rand(2))              # same
ReverseDiff.gradient(u -> u' * view([1.0, 2.0], :), rand(2)) # same

Candidates:

  • *(x::Adjoint{<:Number, <:TrackedArray{V, D, 1}}, y::AbstractVector) where {V, D} (ReverseDiff)
  • *(u::Adjoint{<:Number, <:AbstractVector}, v::AbstractVector{<:Number}) (LinearAlgebra)

transpose(u) * v works for these operands. This happens on master and with #307. It is related to #308 and #309.

🤖 Generated with Claude Code

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions