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

Arpack.svds is not type stable #137

Closed
mileslucas opened this issue Oct 22, 2021 · 3 comments
Closed

Arpack.svds is not type stable #137

mileslucas opened this issue Oct 22, 2021 · 3 comments

Comments

@mileslucas
Copy link

mileslucas commented Oct 22, 2021

Inferred types from Arpack.svds on dense matrix inputs is failing

MWE:

julia> using Arpack
julia> X = randn(10, 1000);
julia> @code_warntype Arpack.svds(X; nsv=3)
Variables
  #unused#::Core.Const(Arpack.var"#svds##kw"())
  @_2::NamedTuple{(:nsv,), Tuple{Int64}}
  @_3::Core.Const(Arpack.svds)
  A::Matrix{Float64}
  kwargs...::Base.Iterators.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:nsv,), Tuple{Int64}}}

Body::Tuple{LinearAlgebra.SVD, Any, Any, Any, Any}
1 ─      (kwargs... = Base.pairs(@_2))
│   %2 = Arpack.:(var"#svds#40")(kwargs...::Core.PartialStruct(Base.Iterators.Pairs{Symbol, Int64, Tuple{Symbol}, NamedTuple{(:nsv,), Tuple{Int64}}}, Any[NamedTuple{(:nsv,), Tuple{Int64}}, Core.Const((:nsv,))]), @_3, A)::Tuple{LinearAlgebra.SVD, Any, Any, Any, Any}
└──      return %2

(in the REPL the Body return type is red, and Test.@inferred calls fail)

system info:

Julia Version 1.6.0
Commit f9720dc2eb* (2021-03-24 12:55 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin20.3.0)
  CPU: Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
@mileslucas
Copy link
Author

Here's some traces from Cthulhu.@descend_code_warntype

│ ─ %-1  = invoke #_svds#47(::Int64,::Bool,::Float64,::Int64,::Int64,::Vector{Float64},::Int64,::typeof(Arpack._svds),::Matrix{Float64})::Tuple{LinearAlgebra.SVD, Any, Any, Any, Any}
Variables
  #_svds#47::Core.Const(Arpack.var"#_svds#47")
  nsv@_2::Int64
  ritzvec::Bool
  tol::Float64
  maxiter::Int64
  ncv::Int64
  v0::Vector{Float64}
  check::Int64
  @_9::Core.Const(Arpack._svds)
  X::Matrix{Float64}
  #48::Arpack.var"#48#49"{_A} where _A
  @_12::Int64
  U::Any
  V::Any
  svals::Any
  r::Any
  firstzero::Any
  threshold::Any
  realex1::Any
  ex::Tuple
  min_mn::Any
  otype::Type{Float64}
  n::Int64
  m::Int64
  nsv@_25::Any
  @_26::Any

it looks like

function _svds(X; nsv::Int = 6, ritzvec::Bool = true, tol::Float64 = 0.0, maxiter::Int = 1000, ncv::Int = 2*nsv, v0::Vector=zeros(eltype(X),(0,)), check::Integer=0)
is the culprit method.

@ViralBShah
Copy link
Collaborator

Issue is #136

@ViralBShah
Copy link
Collaborator

Closing as dup of #136.

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