Skip to content

tsvd type instability #21

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

Closed
mileslucas opened this issue Sep 22, 2020 · 0 comments · Fixed by #22
Closed

tsvd type instability #21

mileslucas opened this issue Sep 22, 2020 · 0 comments · Fixed by #22

Comments

@mileslucas
Copy link

Hello all, I was doing some type-inference testing on my package code and concluded the instability is from calling tsvd. A minimal working example below shows the method is failing to infer the dimension of the output-

julia> using TSVD

julia> X = randn(10, 301*301);

julia> @code_warntype tsvd(X, 5)
Variables
  #self#::Core.Compiler.Const(TSVD.tsvd, false)
  A::Array{Float64,2}
  nvals::Int64
  maxiter::Int64
  initvec::Array{Float64,1}
  tolconv::Float64
  tolreorth::Float64
  stepsize::Int64
  debug::Bool

Body::Tuple{Vararg{AbstractArray{Float64,N} where N,N} where N}
1 ─       (maxiter = 1000)
│   %2  = TSVD.eltype(A)::Core.Compiler.Const(Float64, false)
│   %3  = TSVD.float(%2)::Core.Compiler.Const(Float64, false)
│   %4  = Core.apply_type(TSVD.Vector, %3)::Core.Compiler.Const(Array{Float64,1}, false)
│   %5  = TSVD.size(A, 1)::Int64%6  = TSVD.randn(%5)::Array{Float64,1}
│         (initvec = TSVD.convert(%4, %6))
│   %8  = TSVD.eltype(initvec)::Core.Compiler.Const(Float64, false)
│   %9  = TSVD.real(%8)::Core.Compiler.Const(Float64, false)
│   %10 = TSVD.eps(%9)::Core.Compiler.Const(2.220446049250313e-16, false)
│         (tolconv = TSVD.sqrt(%10))
│   %12 = TSVD.eltype(initvec)::Core.Compiler.Const(Float64, false)
│   %13 = TSVD.real(%12)::Core.Compiler.Const(Float64, false)
│   %14 = TSVD.eps(%13)::Core.Compiler.Const(2.220446049250313e-16, false)
│         (tolreorth = TSVD.sqrt(%14))
│   %16 = TSVD.div(nvals, 10)::Int64
│         (stepsize = TSVD.max(1, %16))
│         (debug = false)
│   %19 = TSVD.:(var"#tsvd#7")(maxiter::Core.Compiler.Const(1000, false), initvec, tolconv, tolreorth, stepsize, debug::Core.Compiler.Const(false, false), #self#, A, nvals)::Tuple{Vararg{AbstractArray{Float64,N} where N,N} where N}
└──       return %19

emphasis %19 = ...::Tuple{Vararg{AbstractArray{Float64,N} where N,N} where N}

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

Successfully merging a pull request may close this issue.

1 participant