@@ -16,60 +16,3 @@ function _scatter(aggr,
16
16
dstsize = (size (src)[1 : (end - 1 )]. .. , n)
17
17
return NNlib. scatter (aggr, src, idx; dstsize)
18
18
end
19
-
20
- # # TO MOVE TO NNlib ######################################################
21
-
22
- # ## Considers the src a zero dimensional object.
23
- # ## Useful for implementing `StatsBase.counts`, `degree`, etc...
24
- # ## function NNlib.scatter!(op, dst::AbstractArray, src::Number, idx::AbstractArray)
25
- # ## for k in CartesianIndices(idx)
26
- # ## # dst_v = NNlib._view(dst, idx[k])
27
- # ## # dst_v .= (op).(dst_v, src)
28
- # ## dst[idx[k]] .= (op).(dst[idx[k]], src)
29
- # ## end
30
- # ## dst
31
- # ## end
32
-
33
- # 10 times faster than the generic version above.
34
- # All the speedup comes from not broadcasting `op`, i dunno why.
35
- # function NNlib.scatter!(op, dst::AbstractVector, src::Number, idx::AbstractVector{<:Integer})
36
- # for i in idx
37
- # dst[i] = op(dst[i], src)
38
- # end
39
- # end
40
-
41
- # # NNlib._view(X, k) = view(X, k...)
42
- # # NNlib._view(X, k::Union{Integer, CartesianIndex}) = view(X, k)
43
- #
44
- # # Considers src as a zero dimensional object to be scattered
45
- # # function NNlib.scatter(op,
46
- # # src::Tsrc,
47
- # # idx::AbstractArray{Tidx,Nidx};
48
- # # init = nothing, dstsize = nothing) where {Tsrc<:Number,Tidx,Nidx}
49
- # # dstsz = isnothing(dstsize) ? maximum_dims(idx) : dstsize
50
- # # dst = similar(src, Tsrc, dstsz)
51
- # # xinit = isnothing(init) ? scatter_empty(op, Tsrc) : init
52
- # # fill!(dst, xinit)
53
- # # scatter!(op, dst, src, idx)
54
- # # end
55
-
56
- # function scatter_scalar_kernel!(op, dst, src, idx)
57
- # index = threadIdx().x + (blockIdx().x - 1) * blockDim().x
58
-
59
- # @inbounds if index <= length(idx)
60
- # CUDA.@atomic dst[idx[index]...] = op(dst[idx[index]...], src)
61
- # end
62
- # return nothing
63
- # end
64
-
65
- # function NNlib.scatter!(op, dst::AnyCuArray, src::Number, idx::AnyCuArray)
66
- # max_idx = length(idx)
67
- # args = op, dst, src, idx
68
-
69
- # kernel = @cuda launch=false scatter_scalar_kernel!(args...)
70
- # config = launch_configuration(kernel.fun; max_threads=256)
71
- # threads = min(max_idx, config.threads)
72
- # blocks = cld(max_idx, threads)
73
- # kernel(args...; threads=threads, blocks=blocks)
74
- # return dst
75
- # end
0 commit comments