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

allocate_result type-unstable for ProductArray #246

Closed
sethaxen opened this issue Nov 6, 2020 · 1 comment · Fixed by #247
Closed

allocate_result type-unstable for ProductArray #246

sethaxen opened this issue Nov 6, 2020 · 1 comment · Fixed by #247

Comments

@sethaxen
Copy link
Member

sethaxen commented Nov 6, 2020

allocate_result is type-unstable for ProductArray. This appears to be due to type-instability of ManifoldsBase.allocate_result_type for this type. This drastically slows down our allocating functions on product manifolds. Here's an example:

using Manifolds, Test
M = Euclidean(2) × Euclidean(3)
parray(x) = Manifolds.ProductArray(Manifolds.ShapeSpecification(Manifolds.StaticReshaper(), M.manifolds...), x)
p = parray(randn(5))

julia> @inferred Manifolds.allocate_result(M, Manifolds.log, p, p)
ERROR: return type Manifolds.ProductArray{Manifolds.ShapeSpecification{(1:2, 3:5), Tuple{Tuple{2}, Tuple{3}}, Tuple{Manifolds.StaticReshaper, Manifolds.StaticReshaper}}, Float64, 1, Vector{Float64}, Tuple{Manifolds.SizedAbstractArray{Tuple{2}, Float64, 1, 1, SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}}, Manifolds.SizedAbstractArray{Tuple{3}, Float64, 1, 1, SubArray{Float64, 1, Vector{Float64}, Tuple{UnitRange{Int64}}, true}}}, Tuple{Manifolds.StaticReshaper, Manifolds.StaticReshaper}} does not match inferred return type Manifolds.ProductArray{Manifolds.ShapeSpecification{(1:2, 3:5), Tuple{Tuple{2}, Tuple{3}}, Tuple{Manifolds.StaticReshaper, Manifolds.StaticReshaper}}, T, 1, _B, _C, Tuple{Manifolds.StaticReshaper, Manifolds.StaticReshaper}} where _C<:Tuple where _B<:AbstractVector{T} where T
Stacktrace:
[1] error(s::String)
    @ Base ./error.jl:33
[2] top-level scope
    @ REPL[17]:1
@mateuszbaran
Copy link
Member

Thanks, I'll check that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants