Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/utils/device.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export device, send_to_host, send_to_device

using ElasticArrays
using Flux
using CUDA
using Adapt
Expand All @@ -22,6 +23,8 @@ send_to_device(
<:Any,
<:Base.ReshapedArray{<:Any,<:Any,<:SubArray{<:Any,<:Any,<:CircularArrayBuffer}},
},
SubArray{<:Any,<:Any,<:ElasticArray,<:Any,<:Any},
ElasticArray,
},
) = CuArray(x)

Expand All @@ -37,6 +40,7 @@ device(::CuArray) = Val(:gpu)
device(::Array) = Val(:cpu)
device(x::Tuple{}) = nothing
device(x::NamedTuple{(),Tuple{}}) = nothing
device(x::ElasticArray) = device(x.data)

function device(x::Random.AbstractRNG)
if x isa CUDA.CURAND.RNG
Expand Down