This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly handle adjoints of wrapped arrays (#90)
* fix: correctly handle adjoints of wrapped arrays * fix: use fast paths for adapt * fix: adapt ranges to JuliaGPU/Adapt.jl#86
- Loading branch information
Showing
9 changed files
with
44 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
name = "MLDataDevices" | ||
uuid = "7e8f7934-dd98-4c1a-8fe8-92b47a384d40" | ||
authors = ["Avik Pal <[email protected]> and contributors"] | ||
version = "1.4.1" | ||
version = "1.4.2" | ||
|
||
[deps] | ||
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e" | ||
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20" | ||
Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196" | ||
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" | ||
Preferences = "21216c6a-2e73-6563-6e65-726566657250" | ||
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" | ||
|
||
|
@@ -47,14 +46,13 @@ MLDataDevicesoneAPIExt = ["GPUArrays", "oneAPI"] | |
|
||
[compat] | ||
AMDGPU = "0.9.6, 1" | ||
Adapt = "4" | ||
Adapt = "4.1" | ||
CUDA = "5.2" | ||
ChainRulesCore = "1.23" | ||
Compat = "4.15" | ||
FillArrays = "1" | ||
Functors = "0.4.8" | ||
GPUArrays = "10, 11" | ||
LinearAlgebra = "1.10" | ||
MLUtils = "0.4.4" | ||
Metal = "1" | ||
Preferences = "1.4" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
module MLDataDevicesChainRulesCoreExt | ||
|
||
using Adapt: Adapt | ||
using ChainRulesCore: ChainRulesCore, NoTangent, @non_differentiable | ||
using ChainRulesCore: ChainRulesCore, NoTangent, ProjectTo, @non_differentiable | ||
|
||
using MLDataDevices: AbstractDevice, UnknownDevice, get_device, get_device_type | ||
|
||
@non_differentiable get_device(::Any) | ||
@non_differentiable get_device_type(::Any) | ||
|
||
function ChainRulesCore.rrule( | ||
::typeof(Adapt.adapt_storage), to::AbstractDevice, x::AbstractArray) | ||
∇adapt_storage = let dev = get_device(x) | ||
if dev === nothing || dev isa UnknownDevice | ||
function ChainRulesCore.rrule(::typeof(Adapt.adapt), to::AbstractDevice, x::AbstractArray) | ||
dev = get_device(x) | ||
y = Adapt.adapt_storage(to, x) | ||
if dev === nothing || dev isa UnknownDevice | ||
dev isa UnknownDevice && | ||
@warn "`get_device(::$(typeof(x)))` returned `$(dev)`." maxlog=1 | ||
Δ -> (NoTangent(), NoTangent(), Δ) | ||
else | ||
Δ -> (NoTangent(), NoTangent(), dev(Δ)) | ||
∇adapt_storage_unknown = Δ -> (NoTangent(), NoTangent(), Δ) | ||
return y, ∇adapt_storage_unknown | ||
else | ||
∇adapt_storage = let dev = dev, x = x | ||
Δ -> (NoTangent(), NoTangent(), ProjectTo(x)(dev(Δ))) | ||
end | ||
return Adapt.adapt_storage(to, x), ∇adapt_storage | ||
end | ||
return Adapt.adapt_storage(to, x), ∇adapt_storage | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ece7ba2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JuliaRegistrator register
ece7ba2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Registration pull request created: JuliaRegistries/General/118090
Tip: Release Notes
Did you know you can add release notes too? Just add markdown formatted text underneath the comment after the text
"Release notes:" and it will be added to the registry PR, and if TagBot is installed it will also be added to the
release that TagBot creates. i.e.
To add them here just re-invoke and the PR will be updated.
Tagging
After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.
This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via: