-
Notifications
You must be signed in to change notification settings - Fork 78
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
Fix Base.mapreduce
to match the new signature in 0.7/1.0
#145
Conversation
…d in Julia 0.7/1.0, namely moving `dims` and `v0` into kwargs
Base.mapreduce
to match the new signature in 0.7/1.0Base.mapreduce
to match the new signature in 0.7/1.0
Thanks! It would be greatly appreciated if you can add testcases for this as well! |
Apologies for the messy commit that combines different changes I made. I'll try to make a new branch for each fix next time.
|
src/abstractarray.jl
Outdated
|
||
for (atype, op) in | ||
[(:(GPUArray), :(Array)), | ||
(:(LinearAlgebra.Adjoint{<:Any,<:GPUArray}), :(x->LinearAlgebra.adjoint(Array(x.parent)))), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe use Base.parent
instead of accessing the field directly
src/testsuite.jl
Outdated
@@ -49,6 +49,7 @@ end | |||
Runs the entire GPUArrays test suite on array type `AT` | |||
""" | |||
function test(AT::Type{<:GPUArray}) | |||
GPUArrays.allowscalar(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my reasoning here was that implementations can decide themselves if they want to assert scalar indexing, eg. https://github.com/JuliaGPU/CuArrays.jl/blob/master/test/runtests.jl#L27
but then it probably needs to be added to the JLArray tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then maybe moving scalar indexing assertion into runtest.jl of GPUArrays package for JLArray tests, like
@testset "JLArray" begin
local _prev = GPUArrays._allowscalar[]
GPUArrays.allowscalar(false)
GPUArrays.test(JLArray)
GPUArrays._allowscalar[] = _prev
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something like that, yeah. But we can leave that for a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(something like @allowscalar
, eg. @disallowscalar
would be cleaner then, not having to work with unexported values in GPUArrays)
Fixed wrapper field access, will submit a separate PR for the test suite behaviour change. |
Thanks! Too bad we can't run CI on this, guess we'll have to keep a close eye on master after merging PRs like this. |
OK, so this apparently broke CuArrays (as per CI), due to passing a CPU array to the GPU. Did you test with CuArrays.jl? Once JuliaLang/METADATA.jl#17380 is merged CI will report better errors. EDIT: ah yeah, this is just mapreduce being implemented without kwargs in GPUArrays. |
Hmm, don't know why the added unit test broke CuArrays. CUDAnative fails to compile the GPU kernel for some reason. Right now it seems that it is the occurrence of EDIT4: @maleadt I've submitted another PR #151 to attempt to workaround the problem. It seems to me the problem here is julia> begin
local a = 1
local b = Int32
local c = one(b)
local d = Ref(1)
local f(x) = x
local g(x) = x + a
local h(x) = x + one(b)
const j(x) = x + one(b)
local k(x) = x + c
local l(x) = x + d[]
println(isbitstype(typeof(f)))
println(isbitstype(typeof(g)))
println(isbitstype(typeof(h)))
println(isbitstype(typeof(j)))
println(isbitstype(typeof(k)))
println(isbitstype(typeof(l)))
end
true
true
false
true
true
false EDIT1: not an anonymous function |
In Julia 0.7/1.0, the signature of
Base.mapreduce
and its alternative functionBase.mapreducedim
which allows adims
argument, have changed to use keyword arguments, i.e.from
mapreduce(f, op[, v0], itr)
mapreducedim(f, op, itr, region[, v0])
to
mapreduce(f, op, itr; dims=:, [init])
It seems that the bot wasn't able to figure out that this is deprecated syntax. The current head is still passing tests since no test case tries to pass a customised initial value to it.