JuliaGPU/CUDA.jl

3 arguments LinearAlgebra.dot

Open

#1,565 建立於 2022年7月18日

在 GitHub 查看
 (0 留言) (1 反應) (0 負責人)Julia (274 fork)batch import
cuda arrayenhancementgood first issue

倉庫指標

Star
 (1,408 star)
PR 合併指標
 (平均合併 5天 5小時) (30 天內合併 16 個 PR)

描述

Is your feature request related to a problem? Please describe.

I would like to be able to use LinearAlgebra's 3 arguments dot function to be able to do compute the dot product dot(x, A*y) between two vectors x and A*y where A is a matrix. Currently, the only way to do this is to call directly dot(x, A*y) which works fine but stores in memory A*y.

Describe the solution you'd like The 3-args dot is there as a performance optimization of dot(x, A*y) , essentially because there is no intermediate result to store. Perhaps there could be a CUDA version of it?

Describe alternatives you've considered Right now, I am managing by using the following (for now, I only need the dot product for Diagonal matrices, but I might some day need it for any matrix): LinearAlgebra.dot(x::AbstractGPUArray, D::Diagonal,y::AbstractGPUArray) = dot(x,D*y)

Additional context I guess my workaround could be added in the CUDA package (or perhaps GPUArrays, but I didn't see the 2-args dot there, so we would need to start by that), but maybe it's better for the script to crash rather than to have non-optimal performance (which is, after all, why the 3-args dot is there for). What would you prefer?

貢獻者指南