# Are there any way to copy a Union Array to GPU with CUDA.jl?

**URL:** <https://discourse.julialang.org/t/are-there-any-way-to-copy-a-union-array-to-gpu-with-cuda-jl/50272>\
**Category:** GPU\
**Tags:** question\
**Created:** [November 17, 2020, 5:22am UTC](https://discourse.julialang.org/t/are-there-any-way-to-copy-a-union-array-to-gpu-with-cuda-jl/50272 "2020-11-17T05:22:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HaoxuanGuo](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/haoxuanguo/32/19052_2.png) [@HaoxuanGuo](https://discourse.julialang.org/u/HaoxuanGuo)\
**Post date:** [November 17, 2020, 5:22am UTC](https://discourse.julialang.org/t/are-there-any-way-to-copy-a-union-array-to-gpu-with-cuda-jl/50272/1 "2020-11-17T05:22:31Z")

</div>

Look at this example

```julia
abstract type AbstractTest end
struct ATest <: AbstractTest end
struct BTest <: AbstractTest end

struct CTest{T <: AbstractTest}
    a::T
end

using CUDA

CuArray([CTest(ATest()), CTest(BTest())])

```

Are there any method or trick to copy `[CTest(ATest()), CTest(BTest())]` to GPU with `CUDA.jl`?

---

<div class="post-metadata">

**Author:** ![maleadt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/maleadt/32/10097_2.png) [@maleadt](https://discourse.julialang.org/u/maleadt)\
**Post date:** [November 17, 2020, 7:13am UTC](https://discourse.julialang.org/t/are-there-any-way-to-copy-a-union-array-to-gpu-with-cuda-jl/50272/2 "2020-11-17T07:13:41Z")

</div>

No, Union arrays have complicated layout and are currently not supported.
