Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CUDACore/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ CUDA_Runtime_jll = "0.22"
ChainRulesCore = "1"
EnzymeCore = "0.8.2"
ExprTools = "0.1"
GPUArrays = "11.5"
GPUArrays = "11.5.4"
GPUCompiler = "1.10"
GPUToolbox = "1.1"
KernelAbstractions = "0.9.38"
Expand Down
6 changes: 3 additions & 3 deletions lib/cublas/src/linalg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,16 @@ function LinearAlgebra.:(*)(transx::Transpose{<:Any,<:StridedCuVector{T}},
return dotu(n, x, y)
end

function LinearAlgebra.norm(x::DenseCuArray{<:Union{Float16, ComplexF16, CublasFloat}},
function LinearAlgebra.norm(x::StridedCuVecOrDenseMat{<:Union{Float16, ComplexF16, CublasFloat}},
p::Real=2)
if p == 2
return nrm2(x)
else
return invoke(norm, Tuple{AbstractGPUArray, Real}, x, p)
return invoke(norm, Tuple{AnyGPUArray, Real}, x, p)
end
end
LinearAlgebra.norm(x::Diagonal{T, <:StridedCuVector{T}}, p::Real=2) where {T<:Union{Float16, ComplexF16, CublasFloat}} = norm(x.diag, p)
LinearAlgebra.norm2(x::DenseCuArray{<:Union{Float16, ComplexF16, CublasFloat}}) = nrm2(x)
LinearAlgebra.norm2(x::StridedCuVecOrDenseMat{<:Union{Float16, ComplexF16, CublasFloat}}) = nrm2(x)

LinearAlgebra.BLAS.asum(x::StridedCuArray{<:CublasFloat}) = asum(length(x), x)

Expand Down
13 changes: 13 additions & 0 deletions lib/cublas/test/level1/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,19 @@ using LinearAlgebra
@test norm(dDx, 2) ≈ norm(Dx, 2)
@test norm(dDx, Inf) ≈ norm(Dx, Inf)
end

@testset "norm of strided views" begin # JuliaGPU/CUDA.jl#2280
# 1D contiguous view: should hit the cuBLAS nrm2 fast path.
x = rand(T, m)
dx = CuArray(x)
@test norm(@view(dx[2:end-1]), 2) ≈ norm(@view(x[2:end-1]), 2)
# Multi-dim non-contiguous view: must avoid scalar iteration.
y = rand(T, 10, 10)
dy = CuArray(y)
@test norm(@view(dy[2:end-1, 2:end-1]), 1) ≈ norm(@view(y[2:end-1, 2:end-1]), 1)
@test norm(@view(dy[2:end-1, 2:end-1]), 2) ≈ norm(@view(y[2:end-1, 2:end-1]), 2)
@test norm(@view(dy[2:end-1, 2:end-1]), Inf) ≈ norm(@view(y[2:end-1, 2:end-1]), Inf)
end
end

@testset for T in [Float16, ComplexF16]
Expand Down