Skip to content

Commit

Permalink
Add EnzymeCore extension
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Jun 2, 2024
1 parent 1b3741c commit 23cf805
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/GPUArraysCore/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ version = "0.1.6"
[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"

[weakdeps]
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869"

[extensions]
EnzymeCoreExt = "EnzymeCore"

[compat]
Adapt = "4.0"
julia = "1.6"
EnzymeCore = "0.6, 0.7"
27 changes: 27 additions & 0 deletions lib/GPUArraysCore/ext/EnzymeCoreExt.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# compatibility with EnzymeCore

module EnzymeCoreExt

using GPUArraysCore

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

function EnzymeCore.EnzymeRules.inactive_noinl(::typeof(GPUArraysCore.default_scalar_indexing), args...)
return nothing
end

function EnzymeCore.EnzymeRules.inactive_noinl(::typeof(GPUArraysCore.assertscalar), args...)
return nothing
end

function EnzymeCore.EnzymeRules.inactive_noinl(::typeof(GPUArraysCore.allowscalar), args...)
return nothing
end

end # module
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
EnzymeCore = "f151be2c-9106-41f4-ab19-57ee4f262869"
JLArrays = "27aeb0d3-9eb9-45fb-866b-73c2ecf80fcb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Expand Down
9 changes: 9 additions & 0 deletions test/gpuarrayscore.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Test, GPUArraysCore, EnzymeCore

@testset "EnzymeCore" begin
@test nothing == EnzymeCore.EnzymeRules.inactive_noinl(GPUArraysCore.assertscalar)

@test nothing == EnzymeCore.EnzymeRules.inactive_noinl(GPUArraysCore.default_scalar_indexing)

@test nothing == EnzymeCore.EnzymeRules.inactive_noinl(GPUArraysCore.allowscalar, identity)
end
4 changes: 4 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
using GPUArrays, Test, Pkg

@tests "GPUArraysCore" begin
include("gpuarrayscore.jl")
end

include("testsuite.jl")

@testset "JLArray" begin
Expand Down

0 comments on commit 23cf805

Please sign in to comment.