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

[NDTensors] Use PackageExtensionCompat #1248

Merged
merged 1 commit into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
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: 2 additions & 2 deletions NDTensors/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ Functors = "d9f16b24-f501-4c13-a1f2-28368ffc5196"
HDF5 = "f67ccb44-e63f-5c2f-98bd-6dc0ccc4ba2f"
InlineStrings = "842dd82b-1e85-43dc-bf29-5d0ee9dffc48"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
PackageExtensionCompat = "65ce6f38-6b18-4e1d-a461-8949797d7930"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SimpleTraits = "699a6c99-e7fa-54fc-8d76-47d257e15c1d"
SplitApplyCombine = "03a91e81-4c3e-53e1-a0a4-9c0c8f19dd66"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
Expand Down Expand Up @@ -47,8 +47,8 @@ Functors = "0.2, 0.3, 0.4"
HDF5 = "0.14, 0.15, 0.16, 0.17"
InlineStrings = "1"
LinearAlgebra = "1.6"
PackageExtensionCompat = "1"
Random = "1.6"
Requires = "1.1"
SimpleTraits = "0.9.4"
SplitApplyCombine = "1.2.2"
StaticArrays = "0.12, 1.0"
Expand Down
13 changes: 3 additions & 10 deletions NDTensors/ext/NDTensorsCUDAExt/NDTensorsCUDAExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,9 @@ using NDTensors.Unwrap
using Adapt
using Functors
using LinearAlgebra

if isdefined(Base, :get_extension)
using CUDA
using CUDA.CUBLAS
using CUDA.CUSOLVER
else
using ..CUDA
using .CUBLAS
using .CUSOLVER
end
using CUDA
using CUDA.CUBLAS
using CUDA.CUSOLVER

include("imports.jl")
include("default_kwargs.jl")
Expand Down
6 changes: 1 addition & 5 deletions NDTensors/ext/NDTensorsMetalExt/NDTensorsMetalExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,7 @@ using NDTensors
using NDTensors.SetParameters
using NDTensors.Unwrap: qr_positive, ql_positive, ql

if isdefined(Base, :get_extension)
using Metal
else
using ..Metal
end
using Metal

include("imports.jl")
include("adapt.jl")
Expand Down
7 changes: 1 addition & 6 deletions NDTensors/ext/NDTensorsOctavianExt/NDTensorsOctavianExt.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
module NDTensorsOctavianExt

using NDTensors

if isdefined(Base, :get_extension)
using Octavian
else
using ..Octavian
end
using Octavian

include("import.jl")
include("octavian.jl")
Expand Down
7 changes: 1 addition & 6 deletions NDTensors/ext/NDTensorsTBLISExt/NDTensorsTBLISExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ module NDTensorsTBLISExt

using NDTensors
using LinearAlgebra
if isdefined(Base, :get_extension)
using TBLIS
else
using ..TBLIS
end
isdefined(Base, :get_extension) ? (using TBLIS) : (using ..TBLIS)
using TBLIS

import NDTensors.contract!

Expand Down
25 changes: 2 additions & 23 deletions NDTensors/src/NDTensors.jl
Original file line number Diff line number Diff line change
Expand Up @@ -295,10 +295,6 @@ end
# Optional backends
#

if !isdefined(Base, :get_extension)
using Requires
end

const _using_tblis = Ref(false)

using_tblis() = _using_tblis[]
Expand All @@ -315,26 +311,9 @@ end

function backend_octavian end

using PackageExtensionCompat
function __init__()
@static if !isdefined(Base, :get_extension)
@require TBLIS = "48530278-0828-4a49-9772-0f3830dfa1e9" begin
enable_tblis()
include("../ext/NDTensorsTBLISExt/NDTensorsTBLISExt.jl")
end
@require Octavian = "6fd5a793-0b7e-452c-907f-f8bfe9c57db4" begin
include("../ext/NDTensorsOctavianExt/NDTensorsOctavianExt.jl")
end

@require CUDA = "052768ef-5323-5732-b1bb-66c8b64840ba" begin
if CUDA.functional()
include("../ext/NDTensorsCUDAExt/NDTensorsCUDAExt.jl")
end
end

@require Metal = "dde4c033-4e86-420c-a63e-0dd931031962" begin
include("../ext/NDTensorsMetalExt/NDTensorsMetalExt.jl")
end
end
@require_extensions
end

end # module NDTensors
Loading