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

StaticMatrix in Struct - ERROR: Unsupported Active... #1069

Closed
Finn-Sueberkrueb opened this issue Sep 23, 2023 · 2 comments
Closed

StaticMatrix in Struct - ERROR: Unsupported Active... #1069

Finn-Sueberkrueb opened this issue Sep 23, 2023 · 2 comments

Comments

@Finn-Sueberkrueb
Copy link

When I use a StaticMatrix from (StaticArrays.jl) inside a struct I get the following error. If I use the StaticMatrix without the struct everything works.

  • Julia 1.9.3
  • Enzyme v0.11.7 [7da242da]
  • StaticArrays v1.6.3 [90137ffa]

A minimal example:

using Enzyme, StaticArrays;

function f(x, loss, M::SMatrix{2,2,Float64}, param)
    
    # No problem with this multiplication
    y1 = M * x
    loss[] += sum(y1)

    # ERROR: Unsupported Active{SVector{3, Float64}}, consider Duplicated or Const
    y2 = param.M * x
    loss[] += sum(y2) 

    return nothing
end


x = rand(2);
M = SMatrix{2,2,Float64}(1, 0, 0, 1);

struct params
    M::SMatrix{2,2,Float64}
end
const param = params(M);


autodiff(Reverse, f,    Duplicated(x, zero(x)), 
                        Duplicated([0.0], [1.0]),
                        Const(M),
                        Const(param));
ERROR: Unsupported Active{SVector{2, Float64}}, consider Duplicated or Const
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] Active
   @ ~/.julia/packages/EnzymeCore/FAGI4/src/EnzymeCore.jl:51 [inlined]
 [3] runtime_generic_augfwd(activity::Type{Val{(false, true)}}, width::Val{1}, ModifiedBetween::Val{(true, true)}, RT::Val{NamedTuple{(Symbol("1"), Symbol("2"), Symbol("3")), Tuple{Any, Any, Any}}}, f::typeof(sum), df::Nothing, primal_1::SVector{2, Float64}, shadow_1_1::SVector{2, Float64})
   @ Enzyme.Compiler ~/.julia/packages/Enzyme/Z027x/src/compiler.jl:1263
@Finn-Sueberkrueb
Copy link
Author

The problem does not occur in Forward mode.

@wsmoses
Copy link
Member

wsmoses commented Sep 23, 2023

Will be fixed in: #1071

@wsmoses wsmoses closed this as completed Sep 23, 2023
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

2 participants