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

Conversion of basis to input type can fail #559

Open
gdalle opened this issue Oct 9, 2024 · 0 comments
Open

Conversion of basis to input type can fail #559

gdalle opened this issue Oct 9, 2024 · 0 comments
Labels
core Related to the core utilities of the package

Comments

@gdalle
Copy link
Owner

gdalle commented Oct 9, 2024

The reason is that I use zero in DI.basis to construct basis vectors, and zero(x) doesn't necessarily have the same type as x. Subsequently, when I convert dx for Enzyme to ensure that Duplicated gets two arguments of the same type, I get an error.

julia> x = view(ones(2), 1:2)
2-element view(::Vector{Float64}, 1:2) with eltype Float64:
 1.0
 1.0

julia> zero(x)
2-element Vector{Float64}:
 0.0
 0.0

julia> convert(typeof(x), zero(x))
ERROR: MethodError: Cannot `convert` an object of type Vector{Float64} to an object of type SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}

Detected in SciML/NonlinearSolve.jl#476 (comment)

Enzyme.onehot uses similar so it has the same problem.

Related:

@gdalle gdalle added the core Related to the core utilities of the package label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Related to the core utilities of the package
Projects
None yet
Development

No branches or pull requests

1 participant