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

Is permutdims == moddims ? #260

Closed
NoelAraujo opened this issue Mar 17, 2020 · 1 comment
Closed

Is permutdims == moddims ? #260

NoelAraujo opened this issue Mar 17, 2020 · 1 comment

Comments

@NoelAraujo
Copy link

Looking at the source code, I could not find a function similar to permutedims.
And at ArrayFire documentation, my best guess for an equivalent function is the moddims method.

Please, can someone implement a permutedims for ArrayFire ?!

@NoelAraujo
Copy link
Author

Actually is the reorder command.
It is already available, and I was straightforward to define a version of permutdims for AFArray.

Here an working example

using ArrayFire
toLook = zeros(2,2,3)
toLook[:,:,1] .= 1
toLook[:,:,2] .= 2
toLook[:,:,3] .= 3

af_toLook = AFArray(toLook)

my_permutedims(x::AFArray, newDims::Tuple{Integer, Integer,Integer}) = reorder(x, newDims[1]-1,newDims[2]-1,newDims[3]-1,3)

println("----- CPU ------")
permutedims(toLook,(3,2,1)) |> display
permutedims(toLook,(1,3,2)) |> display
println("----- GPU ------")
my_permutedims(af_toLook,(3,1,2)) |> display
my_permutedims(af_toLook,(1,3,2)) |> display

all(permutedims(toLook,(3,2,1)) .≈ my_permutedims(af_toLook,(3,1,2))) |> display
all(permutedims(toLook,(1,3,2)) .≈ my_permutedims(af_toLook,(1,3,2))) |> display

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

1 participant