JuliaGPU / JuliaGPU/GPUArrays.jl
Problem with `Base.mapreducedim!`
- Dominant language
- Julia
- Stars
- 450
- Forks
- 104
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 10
Description
## Problem 1
method ambiguity for Adjoint
```julia
julia> Base.mapreducedim!(identity, +, CUDA.zeros(4), CUDA.ones(4,4)')
ERROR: MethodError: mapreducedim!(::typeof(identity), ::typeof(+), ::CuArray{Float32, 1, CUDA.Mem.DeviceBuffer}, ::Adjoint{Float32, CuArray{Float32, 2, CUDA.Mem.DeviceBuffer}}) is ambiguous.
Candidates:
mapreducedim!(f, op, R::AnyGPUArray, A::AbstractArray)
@ GPUArrays ~/.julia/packages/GPUArrays/Hd5Sk/src/host/mapreduce.jl:10
mapreducedim!(f, op::Union{typeof(&), typeof(+), typeof(Base._extrema_rf), typeof(Base.add_sum), typeof(max), typeof(min), typeof(|)}, B::AbstractArray, A::Adjoint{T, <:AbstractMatrix} where T)
@ LinearAlgebra ~/.julia/juliaup/julia-1.10.2+0.x64.linux.gnu/share/julia/stdlib/v1.10/LinearAlgebra/src/adjtrans.jl:427
Possible fix, define
mapreducedim!(::Any, ::Union{typeof(&), typeof(+), typeof(Base._extrema_rf), typeof(Base.add_sum), typeof(max), typeof(min), typeof(|)}, ::AnyGPUArray, ::Adjoint{T, <:AbstractMatrix} where T)
Stacktrace:
[1] top-level scope
@ REPL[39]:1
[2] top-level scope
@ ~/.julia/packages/CUDA/htRwP/src/initialization.jl:206
```
## Problem 2
not dropping singleton dims
```julia
julia> Base.mapreducedim!(identity, +, CUDA.zeros(4), CUDA.ones(4,4,4))
4×1×1 CuArray{Float32, 3, CUDA.Mem.DeviceBuffer}:
[:, :, 1] =
16.0
16.0
16.0
16.0
julia> Base.mapreducedim!(identity, +, zeros(4), ones(4,4,4))
4-element Vector{Float64}:
16.0
16.0
16.0
16.0
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Reproduce both examples in the issue, then read host/mapreduce.jl and the referenced LinearAlgebra/src/adjtrans.jl method. Compare the GPU and CPU mapreducedim! results, focusing on the Adjoint ambiguity and singleton dimensions. Done means the ambiguous call dispatches successfully and the GPU result has the same dimensional shape as the CPU result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- julia
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 38/100