Skip to content

Is there a way to write a gather function for slices instead of indices? #542

Answered by tomsmeding
noughtmare asked this question in Q&A
Discussion options

You must be logged in to vote

Is gather' not "just" this?

gather' :: (Shape sh, Elt e, x ~ Int)
        => Acc (Array sh Int)
        -> Acc (Array (Z :. Int :. x) e)
        -> Acc (Array (sh :. x) e)
gather' ixs source =
  let I2 _ len = shape source
  in backpermute
       (shape ixs ::. len)
       (\(ix ::. i) -> I2 (ixs ! ix) i)
       source

Please verify that I correctly interpreted which index goes where :)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@noughtmare
Comment options

Answer selected by noughtmare
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants