JuliaGPU/GPUArrays.jl

Better error for map! misuse

maleadt opened this issue · 0 comments

julia> map!(sqrt, rand(1))
ERROR: ArgumentError: map! requires at least one "source" argument
Stacktrace:
 [1] map!(::typeof(sqrt), ::Vector{Float64})
   @ Base ./abstractarray.jl:3353
 [2] top-level scope
   @ REPL[17]:1
 [3] top-level scope
   @ ~/Julia/pkg/Metal/src/initialization.jl:51

vs

julia> map!(sqrt, Metal.rand(1))
ERROR: InvalidIRError: compiling MethodInstance for (::GPUArrays.var"#map_kernel#27"{Int64})(::Metal.mtlKernelContext, ::MtlDeviceVector{Float32, 1}, ::Base.Broadcast.Broadcasted{Base.Broadcast.DefaultArrayStyle{0}, Nothing, typeof(sqrt), Tuple{}}, ::Int64) resulted in invalid LLVM IR
Reason: unsupported dynamic function invocation (call to sqrt)
Stacktrace:
 [1] _broadcast_getindex_evalf
   @ ./broadcast.jl:683
 [2] _broadcast_getindex
   @ ./broadcast.jl:656
 [3] getindex
   @ ./broadcast.jl:610
 [4] map_kernel
   @ ~/Julia/pkg/GPUArrays/src/host/broadcast.jl:118