I’m trying to implement a neural network which rotates the image within the layers of the network. My question is: is there a way to use something like Base.rotr90
on a CUDA.CuArray while disabling scalar indexing (CUDA.allowscalar(false)
)?
Here’s what I use on the CPU:
a = randn((4, 4, 3, 2))
mapslices(rotr90, a, dims=[1,2])
on the GPU I tried:
using CUDA
CUDA.allowscalar(false)
a = randn((4, 4, 3, 2)) |> Flux.gpu
mapslices(rotr90, a, dims=[1,2])
I get the following error (that scalar indexing is disabled):
ERROR: Scalar indexing is disallowed.
Invocation of getindex resulted in scalar indexing of a GPU array.
This is typically caused by calling an iterating implementation of a method.
Such implementations *do not* execute on the GPU, but very slowly on the CPU,
and therefore are only permitted from the REPL for prototyping purposes.
If you did intend to index this array, annotate the caller with @allowscalar.
Is there any way around this or should I just use scalar indexing?