You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enzyme fails when using a custom type that is based on SMatrix and abstract type labels. The error is discussed here, where @wsmoses suggested that it is "not-yet-implemented" with a workaround to type-stabilize the code.
MWE and its output are below:
using Enzyme
using Random
using StaticArrays
abstract type AbstractBasisType endstruct Contravariant <:AbstractBasisTypeendstruct CurvilinearBasisVectors{N, T, C, B, V <:AbstractBasisType} <:StaticMatrix{N, N, T}
__x::Union{SMatrix{N, N, T}}functionCurvilinearBasisVectors{N, T, C, B, V}(b::AbstractMatrix) where {N, T, C, B, V}
returnnew{N, T, C, B, V}(SMatrix{N, N, T}(b))
endend
Base.@propagate_inboundsfunction Base.getindex(v::CurvilinearBasisVectors{N, T, C, B, V}, i::Int) where {N, T, C, B, V}
returnview(getfield(v, :__x), i)[]
end
basis_labels = (:∇x, :∇y, :∇z);
coord_labels = (:x, :y, :z);
a =CurvilinearBasisVectors{3,Float64,basis_labels,coord_labels,Contravariant}(
rand(3,3),
);
da =CurvilinearBasisVectors{3,Float64,basis_labels,coord_labels,Contravariant}(
zeros(3,3),
);
@show a,da
functionf(x, y)
sum(sum(y .* x))
end@showf(a, 2.0)
@showautodiff(Reverse, f, Active, Duplicated(a, da), Active(2.0))
@show da
Enzyme fails when using a custom type that is based on
SMatrix
andabstract type
labels. The error is discussed here, where @wsmoses suggested that it is "not-yet-implemented" with a workaround to type-stabilize the code.MWE and its output are below:
The text was updated successfully, but these errors were encountered: