JuliaParallel / JuliaParallel/Dagger.jl

`permutedims` function not supported for `Dagger.DArray`

Open
#395 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
723
Forks
90
Avg merge
1d 37m
Merged PRs (30d)
9

Description

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
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
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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.