Skip to content

Add EnzymeCore extension #536

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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing for the exact definition of interface methods isn't good testing. We don't want to have to update tests every time implementation details (of Enzyme or GPUArrays) change. Instead, this should test for observed, meaningful behavior (i.e., why are these definitions needed in the first place).

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
Loading