Closed blacksph3re closed 4 years ago
This won't work, I'm afraid, slicemap
expects a function which gives back the same shape. Because it calls Align
with the same parameters as used for Slices
. But if you only need one half, or you need other mismatched slice/align, it should be dead simple to borrow what you need:
However, mapcols
and MapCols
and friends do accept vector -> scalar functions.
Ah okay, cool - thanks for the lead. I needed slicemap because I am working on a GPU and mapcols returns a CPU array, but I will try directly with JuliennedArrays.
GPU things are tricky... I think mapcols is more-or-less doing a CPU iteration over GPU sub-arrays. When those return CPU arrays then reduce(hcat, Array{CuArray{...
makes the final GPU array, but when they return scalars there is nothing to do. Copying the result back to the GPU may not be the worst idea.
Thread from someone who actually knows what he's talking about:
https://discourse.julialang.org/t/map-performance-with-cuarrays/33497/4
Hey, when I map to a scalar, this throws an error:
slicemap(x -> sum(x), rand(10, 10), dims=1)
Results in
If I use
slicemap(x -> [sum(x)], rand(10, 10), dims=1)
it works