-
Notifications
You must be signed in to change notification settings - Fork 218
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
Suggestion - Disable AbstractArray indexing fallback by default #178
Comments
This is not quite as easy as it sounds, unfortunately. We can't tell in general that scalar indexing is bad (nor that vector indexing is good), so there are a few valid use cases that this would break by default. On top of that, all of the Base That said it would obviously be good to avoid confusion / slowness in some obvious cases. We can easily disable mixed broadcasting, and intercept the fallbacks for unimplemented linalg etc (although most of that stuff should be wrapped by now). |
I think it would make sense to change the default to
but still allow the user to specify
i.e. the reverse of the current situation, since my guess is that the majority of codes out there start with |
Yes, that was basically what I was suggesting. |
A situation where this might degrade the experience: julia> using CUDA
julia> sin.(CUDA.rand(Float32, 2))
2-element CuArray{Float32,1,Nothing}:
0.08872609
0.03352104
julia> sin.(CUDA.rand(Int, 2))
┌ Warning: Performing scalar operations on GPU arrays: This is very slow, consider disallowing these operations with `allowscalar(false)`
└ @ GPUArrays ~/.julia/packages/GPUArrays/HGtNV/src/host/indexing.jl:43
ERROR: MethodError: no method matching sin(::Int64)
You may have intended to import Base.sin A failing broadcast falls back to scalar iteration -- disabling so would result in never seeing the MethodError. We could make the warning scarier though. |
Can we have a global settings for disabling scaler index? like a environment variable? |
Oh I found the ENV["JULIA_GPU_ALLOWSCALAR"] in source code... how about a doc for that? |
If you mix CuArrays with Base Arrays, you get the slow version of things. I think this should best be disabled by default and give a nice error. Users should be able to opt in to enable it.
The text was updated successfully, but these errors were encountered: