Skip to content

Conversion of basis to input type can fail #559

Open
@gdalle

Description

@gdalle

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:

Metadata

Metadata

Assignees

No one assigned

    Labels

    coreRelated to the core utilities of the package

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions