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?

贡献者指南