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

Add a dispatch for LinearAlgebra.norm2 #2302

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sharanry
Copy link

norm(@view x[..], 2) was previously leading to a call of LinearAlgebra.generic_norm2 which led to a scalar indexing. This catches such cuda subarray norm2 calls earlier.

Inf-norm and p-norm with cuda subarrays still lead to the following dispatches:

LinearAlgebra.generic_normInf(x) = float(mapreduce(norm, max, x))
LinearAlgebra.generic_norm1(x) = mapreduce(float  norm, +, x)

I am not sure if there is a better way to dispatch the above.

should resolve #2280

`norm(@view x[..], 2)` was previously leading to a call of `LinearAlgebra.generic_norm2` which led to a scalar indexing. This catches such cuda subarray norm2 calls earlier.

Inf-norm and p-norm with cuda subarrays still lead to the following dispatches:
```julia
LinearAlgebra.generic_normInf(x) = float(mapreduce(norm, max, x))
LinearAlgebra.generic_norm1(x) = mapreduce(float ∘ norm, +, x)
```
I am not sure if there is a better way to dispatch the above.

should resolve JuliaGPU#2280
@maleadt
Copy link
Member

maleadt commented Mar 27, 2024

What about generalizing the LinearAlgebra.norm method above to StridedCuArray? That seems cleaner than overriding an internal method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2-norm for views of CuArray falls back to scalar indexing
2 participants