Skip to content
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

Diagonal(::CuVector) .* ::Number returns full CuMatrix #2140

Open
vpuri3 opened this issue Nov 1, 2023 · 2 comments
Open

Diagonal(::CuVector) .* ::Number returns full CuMatrix #2140

vpuri3 opened this issue Nov 1, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@vpuri3
Copy link
Contributor

vpuri3 commented Nov 1, 2023

julia> Diagonal(CUDA.ones(4)) .* 4f0
4×4 CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}:
 4.0  0.0  0.0  0.0
 0.0  4.0  0.0  0.0
 0.0  0.0  4.0  0.0
 0.0  0.0  0.0  4.0

Should return Diagonal{T, CuVector} like

julia> Diagonal(ones(4)) .* 4f0
4×4 Diagonal{Float64, Vector{Float64}}:
 4.0            
     4.0        
         4.0    
             4.0
@vpuri3 vpuri3 added the bug Something isn't working label Nov 1, 2023
@vpuri3
Copy link
Contributor Author

vpuri3 commented Nov 1, 2023

@maleadt i can add the required method if you can LMK where that needs to be done

vpuri3 added a commit to vpuri3/NonlinearSolve.jl that referenced this issue Nov 1, 2023
The result with / without broadcasting here is the same. Removing the broadcast here would avoid JuliaGPU/CUDA.jl#2140. Further, when `cache.DtD.diag isa ComponentVector` that CUDA bug would lead to scalar indexing error on GPU.
@maleadt
Copy link
Member

maleadt commented Nov 1, 2023

I don't know that by heart; you can check how Base's Broadcast implementation preserves the Diagonal and apply the same logic to the GPUArrays broadcast implementation.

@maleadt maleadt added enhancement New feature or request and removed bug Something isn't working labels Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants