Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings in second order tests #85

Closed
gdalle opened this issue Mar 21, 2024 · 1 comment
Closed

Fix warnings in second order tests #85

gdalle opened this issue Mar 21, 2024 · 1 comment

Comments

@gdalle
Copy link
Member

gdalle commented Mar 21, 2024

They are caused by EnzymeAD/Enzyme.jl#1354, because we define our array-to-scalar scenarios as:

f_vector_scalar(x::AbstractVector)::Number = sum(sin, x)
f_matrix_scalar(x::AbstractMatrix)::Number = sum(sin, x)

If instead we do the following, problem solved, but it allocates:

f_vector_scalar(x::AbstractVector)::Number = sum(sin.(x))
f_matrix_scalar(x::AbstractMatrix)::Number = sum(sin.(x))

We need scalar-valued functions which

  • do not allocate
  • do not use LinearAlgebra
  • have different derivatives for every component

My suggestion would be

function f_vector_scalar(x::AbstractVector)::Number
    s = zero(eltype(x))
    for i in eachindex(x)
        s += sin(i * x[i])
    end
    return s
end

but it causes JuliaDiff/Diffractor.jl#280

@gdalle
Copy link
Member Author

gdalle commented Mar 25, 2024

Disappeared for now because we're no longer testing that specific combination

@gdalle gdalle closed this as not planned Won't fix, can't repro, duplicate, stale Mar 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant