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

Add WIP docstrings to CPU and GPU #1632

Merged
merged 8 commits into from
Aug 22, 2021
Merged
Changes from 3 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
10 changes: 10 additions & 0 deletions src/functor.jl
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,22 @@ function loadparams!(m, xs)
end

# CPU/GPU movement conveniences
"""
cpu(m)

Moves a paticular resource from where it is, onto the CPU.
DhairyaLGandhi marked this conversation as resolved.
Show resolved Hide resolved
"""
cpu(m) = fmap(x -> adapt(Array, x), m)

_isbitsarray(::AbstractArray{<:Number}) = true
_isbitsarray(::AbstractArray{T}) where T = isbitstype(T)
_isbitsarray(x) = false

"""
gpu(x)

Moves a particular resource from where it is, onto the GPU, if available. It is a no-op otherwise.
DhairyaLGandhi marked this conversation as resolved.
Show resolved Hide resolved
logankilpatrick marked this conversation as resolved.
Show resolved Hide resolved
"""
gpu(x) = use_cuda[] ? fmap(CUDA.cu, x; exclude = _isbitsarray) : x

# Precision
Expand Down