-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NDTensorsMetalExt] Update for latest Unwrap
- Loading branch information
Showing
11 changed files
with
90 additions
and
24 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,23 @@ | ||
# Catches a bug in `copyto!` in Metal backend. | ||
function NDTensors.copyto!( | ||
::Type{<:MtlArray}, dest::AbstractArray, ::Type{<:MtlArray}, src::SubArray | ||
function Base.copy(src::Exposed{<:MtlArray,<:Base.ReshapedArray}) | ||
return reshape(copy(parent(src)), size(unexpose(src))) | ||
end | ||
|
||
function Base.copy( | ||
src::Exposed{ | ||
<:MtlArray,<:SubArray{<:Any,<:Any,<:Base.ReshapedArray{<:Any,<:Any,<:Adjoint}} | ||
}, | ||
) | ||
return Base.copyto!(dest, copy(src)) | ||
return copy(@view copy(expose(parent(src)))[parentindices(unexpose(src))...]) | ||
end | ||
|
||
# Catches a bug in `copyto!` in Metal backend. | ||
function Base.copyto!(dest::Exposed{<:MtlArray}, src::Exposed{<:MtlArray,<:SubArray}) | ||
return copyto!(dest, expose(copy(src))) | ||
end | ||
|
||
# Catches a bug in `copyto!` in Metal backend. | ||
function NDTensors.copyto!( | ||
::Type{<:MtlArray}, dest::AbstractArray, ::Type{<:MtlArray}, src::Base.ReshapedArray | ||
function Base.copyto!( | ||
dest::Exposed{<:MtlArray}, src::Exposed{<:MtlArray,<:Base.ReshapedArray} | ||
) | ||
return NDTensors.copyto!(dest, parent(src)) | ||
return copyto!(dest, expose(parent(src))) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Adapt.adapt(to, x::Exposed) = adapt_structure(to, x) | ||
Adapt.adapt_structure(to, x::Exposed) = adapt_structure(to, unexpose(x)) | ||
|
||
# https://github.com/JuliaGPU/Adapt.jl/pull/51 | ||
# TODO: Remove once https://github.com/JuliaGPU/Adapt.jl/issues/71 is addressed. | ||
function Adapt.adapt_structure(to, A::Exposed{<:Any,<:Hermitian}) | ||
return Hermitian(adapt(to, parent(unexpose(A))), Symbol(unexpose(A).uplo)) | ||
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