-
Notifications
You must be signed in to change notification settings - Fork 81
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
Regression mapping over over GPU array and unit range #580
Comments
This is caused by 8dfd805, which was done to resolve an ambiguity. Reinstating that functionality (and adding a test) is as simple as: diff --git a/src/host/broadcast.jl b/src/host/broadcast.jl
index eaa50bb..6c703c4 100644
--- a/src/host/broadcast.jl
+++ b/src/host/broadcast.jl
@@ -82,8 +82,9 @@ end
allequal(x) = true
allequal(x, y, z...) = x == y && allequal(y, z...)
-function Base.map(f, xs::AnyGPUArray...)
+function Base.map(f, x::AnyGPUArray, xs::AbstractArray...)
# if argument sizes match, their shape needs to be preserved
+ xs = (x, xs...)
if allequal(size.(xs)...)
return f.(xs...)
end
@@ -103,7 +104,7 @@ function Base.map(f, xs::AnyGPUArray...)
return map!(f, dest, xs...)
end
-function Base.map!(f, dest::AnyGPUArray, xs::AnyGPUArray...)
+function Base.map!(f, dest::AnyGPUArray, xs::AbstractArray...)
# custom broadcast, ignoring the container size mismatches
# (avoids the reshape + view that our mapreduce impl has to do)
indices = LinearIndices.((dest, xs...))
diff --git a/test/testsuite/broadcasting.jl b/test/testsuite/broadcasting.jl
index 81b028f..b6e852a 100644
--- a/test/testsuite/broadcasting.jl
+++ b/test/testsuite/broadcasting.jl
@@ -143,6 +143,9 @@ function broadcasting(AT, eltypes)
@test compare(AT, rand(ET, 2,2), rand(ET, 2)) do x,y
map!(+, x, y)
end
+ @test compare(AT, rand(ET, 2), 1:2) do x,y
+ map!(+, x, y)
+ end
end
@testset "map $ET" begin
@@ -155,6 +158,9 @@ function broadcasting(AT, eltypes)
@test compare(AT, rand(ET, 2,2), rand(ET, 2)) do x,y
map(+, x, y)
end
+ @test compare(AT, rand(ET, 2), 1:2) do x,y
+ map(+, x, y)
+ end
end
end However, this introduces an ambiguity:
I can't spend time on this right now, so feel free to take a stab. |
This also causes an issue over on CliMA/Oceananigans.jl#4036. However, I think our problem may be resolved by restoring previous behavior of |
On GPUArrays
v10.3.1
,map((x,y)->x+y, CUDA.zeros(2), 1:2)
used to work without causing a scalar indexing issue. However, with the change inv11.1.0
, it now throws the following error:I wonder if this was an intended change.
CUDA.zeros(2) .+ (1:2)
still seems to work on CUDAv5.6
without causing a scalar indexing issue.cc: @frapac, @amontoison
MadNLP/MadNLP.jl#395
The text was updated successfully, but these errors were encountered: