Skip to content
This repository has been archived by the owner on Mar 12, 2021. It is now read-only.

similar(PermutedDimsArray(::CuArray)) isa Array #658

Closed
mcabbott opened this issue Mar 29, 2020 · 1 comment · Fixed by JuliaLang/julia#35304
Closed

similar(PermutedDimsArray(::CuArray)) isa Array #658

mcabbott opened this issue Mar 29, 2020 · 1 comment · Fixed by JuliaLang/julia#35304
Labels

Comments

@mcabbott
Copy link

similar gives an Array not a CuArray, when acting on a PermutedDimsArray:

julia> similar(PermutedDimsArray(cu(rand(2,2)), (2,1)), 3,3)
3×3 Array{Float32,2}:
...
julia> similar(cu(rand(2,2))', 3,3) # Adjoint is fine
3×3 CuArray{Float32,2,Nothing}:

I'm not certain but it looks like LinearAlgebra may un-wrap Adjoint before calling similar, in which case the difference isn't originating in any JuliaGPU package. Where should the correction live?

Build log, etc

julia> Pkg.build()
  Building NNlib → `~/.julia/packages/NNlib/FAI3o/deps/build.log`
false

julia> versioninfo()
Julia Version 1.3.0
Commit 46ce4d7933 (2019-11-26 06:09 UTC)
Platform Info:
  OS: macOS (x86_64-apple-darwin19.0.0)
  CPU: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-6.0.1 (ORCJIT, skylake)
Environment:
  JULIA_NUM_THREADS = 12

(cu) pkg> st
    Status `~/trash/cu/Project.toml`
  [3895d2a7] CUDAapi v4.0.0 #master (https://github.com/JuliaGPU/CUDAapi.jl.git)
  [c5f51814] CUDAdrv v6.2.2 #master (https://github.com/JuliaGPU/CUDAdrv.jl.git)
  [be33ccc6] CUDAnative v3.0.2 #master (https://github.com/JuliaGPU/CUDAnative.jl.git)
  [3a865a2d] CuArrays v2.0.1 [`~/.julia/dev/CuArrays`]
  [0c68f7d7] GPUArrays v3.1.0 #master (https://github.com/JuliaGPU/GPUArrays.jl.git)
  [872c559c] NNlib v0.6.6

julia> CuArrays.version()
v"10.1.243"
@mcabbott mcabbott added the bug label Mar 29, 2020
@maleadt
Copy link
Member

maleadt commented Mar 30, 2020

This is expected. We can't implement all methods for CuArray on all possible wrapped types that may contain a CuArray, and only do so for some core functions (broadcast, show, etc). Generally the wrapper type should provide this functionality, e.g.
https://github.com/JuliaLang/julia/blob/02624ac0e74a43ef014e96f21887de7052eb3e9c/base/subarray.jl#L73

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

Successfully merging a pull request may close this issue.

2 participants