JuliaSmoothOptimizers / LinearOperators.jl

Linear Operators for Julia
Other
150 stars 32 forks source link

Missing `S` keyword for `opRestriction` #323

Closed nHackel closed 5 months ago

nHackel commented 5 months ago

Hello, I've run into an issue where the opRestriction and in turn the opExtension constructors don't have an S keyword argument. While the operator on its own works with GPU arrays, this causes an issue when trying to build composite ops for a GPU:

julia> using LinearOperators, CUDA

julia> x = CUDA.rand(256);

julia> op = opRestriction(1:128, 256);

julia> op * x # works

julia> (op * opDiagonal(x)) * x # fails
dpo commented 5 months ago

Could you please show the error message?

nHackel commented 5 months ago

The error is:

julia> (op * opDiagonal(x)) * x
ERROR: LinearOperatorException("storage types cannot be promoted to a concrete type")
Stacktrace:
 [1] *(op1::LinearOperator{Int64, Int64, LinearOperators.var"#156#158"{UnitRange{Int64}}, LinearOperators.var"#157#159"{UnitRange{Int64}}, LinearOperators.var"#157#159"{UnitRange{Int64}}, Vector{Int64}}, op2::LinearOperator{Float32, Int64, LinearOperators.var"#146#148"{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}, LinearOperators.var"#146#148"{CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}, LinearOperators.var"#147#149"{typeof(conj), CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}}, CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}})
   @ LinearOperators ~/.julia/dev/LinearOperators.jl/src/operations.jl:119
 [2] top-level scope
   @ REPL[5]:1
 [3] top-level scope
   @ ~/.julia/packages/CUDA/htRwP/src/initialization.jl:206

The storage_type of opRestriction is always Vector{Int64} without the added kwarg from #324