-
Notifications
You must be signed in to change notification settings - Fork 37
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
[Feature request] compatible_multiplicative_operand
interface
#261
Comments
What is |
Ah, some typos, just fixed. |
So the goal is to have a more structured hook for converting the source matrix? |
Exactly. |
I definitely see the utility in this and it would be good help with this. I'm not completely sold on the solution because it's an all in one allocation and trait method for this one specific application. This seems like a place where the overall array interface is lacking in some aspect so it would be great to have some more generic stuff going on that builds to that last step. For example, we could have a trait/constructor that corresponds to each matrix combined and the result is passed to an allocating function. Otherwise it seems like we are headed towards developing many independent alternative solutions to These are are just my initial thoughts as someone whose usually interested in the most easily maintained and generalizable solution. There's a lot of set up that goes into composing high performance array operations. For example, TriangularSolve.jl and Octavian.jl put together a lot of information before allocating any new data. Can we have a more structured approach to allocation that works in other high performance situations? |
Is there a reason to not use |
He mentions that doesn't solve the problem here. Elsewhere it was said that it's preferred to be a dense array and if all that's needed is a way to ensure that |
To make it more general purposed, what about In somewhere else, like |
Yeah that was the next question, are you sure this isn't just |
Can you elaborate on |
Base.@pure __parameterless_type(T) = typename(T).wrapper
parameterless_type(x) = parameterless_type(typeof(x))
parameterless_type(x::Type) = __parameterless_type(x) |
Ah, you meant type casting like |
I see. Okay, cool. |
In the discussion under this PR: SciML/ExponentialUtilities.jl#84 . We meet a using case of multipling a linear operator of certain type to a dense matrix. We think it would be fantastic if there is an API called
compatible_multiplicative_operand(target, source)
in ArrayInterface. That is,compatible_multiplicative_operand(::CuArray, dense::Matrix) = CuArray(dense)
compatible_multiplicative_operand(::Matrix, cuarray::CuArray) = Matrix(cuarray)
compatible_multiplicative_operand(::SparseMatrixCSC, dense::Matrix) = dense
compatible_multiplicative_operand(::Matrix, sparse::SparseMatrixCSC) = sparse
Similarly, we can define them for Transpose, Adjoint, SubArray, and ReshapedArray,
DistributedArray
et al.The key point is, we want two arrays can have compatible array types for multiplication, which is quite different from
Base.convert
.The text was updated successfully, but these errors were encountered: