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

Concatenation in 3 dimension missing #400

Closed
vchuravy opened this issue Nov 29, 2018 · 3 comments
Closed

Concatenation in 3 dimension missing #400

vchuravy opened this issue Nov 29, 2018 · 3 comments

Comments

@vchuravy
Copy link

This is particular useful in U-Net and related networks.

function cat3d(arrs...)
          H = size(first(arrs), 1)
          W = size(first(arrs), 2)
          C = sum(size(a, 3) for a in arrs)
          T = size(first(arrs), 4)
          
          @assert all(H == size(a, 1) for a in arrs)
          @assert all(W == size(a, 2) for a in arrs)
          @assert all(T == size(a, 4) for a in arrs)
          
          out = Array{Float64}(undef, H, W, C, T)
          curr = 1
          for (i, A) in enumerate(arrs)
            c = size(A, 3)
            r = curr:(curr+c-1)
            out[:, :, r, :] .= A
            curr += c
          end
          out
end
permutedims(reshape(cat1d(permutedims(A, [1, 2, 4, 3]), ...), H, W, T, C), [1, 2, 4, 3])
@ekinakyurek
Copy link
Collaborator

ekinakyurek commented Nov 29, 2018

First function gives error in Julia 1.0.1.

Below function is working, but I think it is probably slow.

function cat3d2(arrs...)
           parrs = map(x->permutedims(x,(1,2,4,3)), arrs)
           H,W,_,B = size(first(arrs))
           C = sum(size(a, 3) for a in arrs)
           permutedims(reshape(cat1d(parrs...),(H,W,B,C)),(1,2,4,3))
 end

@ekinakyurek
Copy link
Collaborator

There is also #319 .

@denizyuret
Copy link
Owner

I think CuArrays fallbacks fix this in 85c4125

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

No branches or pull requests

3 participants