Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fft2D' and fft3D' fail on arrays where dimension sizes are different #4

Closed
sh54 opened this issue Feb 2, 2017 · 1 comment
Closed

Comments

@sh54
Copy link

sh54 commented Feb 2, 2017

In fft2D'

        fft' a  = A.transpose . fft sign (Z:.width)  height
              >-> A.transpose . fft sign (Z:.height) width
                $ a

should be

        fft' a  = A.transpose . fft sign (Z:.height) width
              >-> A.transpose . fft sign (Z:.width)  height
                $ a

Otherwise an index error is given if supplied some array with a shape like Z :. 8 :. 4.

In fft3D'

scale = P.fromIntegral (width * height) should be scale = P.fromIntegral (depth * width * height).

Also:

        fft' a  = rotate3D . fft sign (Z:.width :.depth)  height
              >-> rotate3D . fft sign (Z:.height:.width)  depth
              >-> rotate3D . fft sign (Z:.depth :.height) width
                $ a

should be

        fft' a  = rotate3D . fft sign (Z:.depth :.height) width
              >-> rotate3D . fft sign (Z:.height:.width)  depth
              >-> rotate3D . fft sign (Z:.width :.depth)  height
                $ a

Otherwise an index error is given if supplied some array with a shape like Z :. 8 :. 4 :. 2.

Also there seems to be an issue with the backpermute call in rotate3D when given an array with a shape like Z :. 8 :. 4 :. 2 so I have used the following replacement as a work around:

rotate3D :: Elt e => Acc (Array DIM3 e) -> Acc (Array DIM3 e)
rotate3D arr = do
  let Z :. k :. l :. m = unlift $ A.shape arr  :: Z :. Exp Int :. Exp Int :. Exp Int
  let sz = lift $ Z :. l :. m :. k
  generate sz $ \ix -> do
    let Z :. l' :. m' :. k' = unlift ix :: Z :. Exp Int :. Exp Int :. Exp Int
    arr ! (index3 k' l' m')

The backpermute issue has been registered here.

I checked my changes against the equivalent numpy code and got the same results. I also quickly checked doing an inverse fft on the fft and got back the original arrays.

This just is an issue for the non-accelerated versions.

@tmcdonell
Copy link
Member

Thanks! I've added both of these fixes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants