Skip to content
New issue

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

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

Already on GitHub? # to your account

permutedims function not supported for Dagger.DArray #395

Open
jofrevalles opened this issue May 19, 2023 · 0 comments
Open

permutedims function not supported for Dagger.DArray #395

jofrevalles opened this issue May 19, 2023 · 0 comments

Comments

@jofrevalles
Copy link

jofrevalles commented May 19, 2023

Hello,
During my usage of DArray in the Dagger.jl library, I encountered an inconsistency between how transpose and permutedims functions operate. While the transpose function works perfectly with DArray, it appears that permutedims is not currently supported.

Here's a minimal example that demonstrates the issue:

julia> darray = distribute(rand(4, 4), Blocks(2, 2))
DArray{Any, 2, typeof(cat)}(4, 4)

julia> transpose(darray) # works fine
Dagger.Transpose{Any, 2}(4, 4)

julia> transpose(darray) |> compute |> collect
4×4 Matrix{Float64}:
 0.167282  0.111796   0.139091   0.76079
 0.970018  0.962297   0.0806159  0.750641
 0.44158   0.213501   0.929178   0.0804493
 0.980127  0.0202904  0.873157   0.249399

julia> permutedims(darray, (2, 1))
4×4 Matrix{Any}:
 Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)
 Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)
 Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)
 Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)  Dagger.GetIndex{Any, 2}(1, 0, 1, 0)

The result of permutedims(darray, (2, 1)) is a matrix of Dagger.GetIndex objects, and attempting to compute the result leads to an error, as shown here:

julia> permutedims(darray, (2, 1)) |> compute
ERROR: MethodError: no method matching compute(::Context, ::Matrix{Any}; options=nothing)
Closest candidates are:
  compute(::Context, ::DArray; persist, options) at ~/.julia/packages/Dagger/vNUsP/src/array/darray.jl:231
  compute(::Context, ::Thunk; options) at ~/.julia/packages/Dagger/vNUsP/src/compute.jl:27
  compute(::Any; options) at ~/.julia/packages/Dagger/vNUsP/src/compute.jl:5
  ...

I couldn't find any documentation addressing this issue, so I thought it might be worth bringing up as a potential enhancement for DArray. The ability to perform arbitrary dimension permutations would enhance the usability of DArray, particularly for tensor computations.

Thanks for your time and all your work on this library!

Best,
Jofre

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

No branches or pull requests

1 participant