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

Add CI testing for EnzymeCore #2009

Merged
merged 3 commits into from
Oct 23, 2024
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
62 changes: 62 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,68 @@ jobs:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # or true if you want CI to fail when Codecov fails
enzymecore:
name: EnzymeCore - Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.libEnzyme }} libEnzyme - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.version == 'nightly' }}
env:
JULIA_PROJECT: "lib/EnzymeCore"
strategy:
fail-fast: false
matrix:
version:
- '1.10'
- ~1.11.0-0
Copy link
Member

Choose a reason for hiding this comment

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

This should just be 1.11

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I took the same versions as for EnzymeTestUtils, feel free to change those in another PR

- 'nightly'
os:
- ubuntu-latest
arch:
- x64
libEnzyme: [packaged]
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v2
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- name: setup EnzymeCore
shell: julia --color=yes {0}
id: setup_testutils
continue-on-error: ${{ matrix.version == 'nightly' }}
run: |
using Pkg
Pkg.develop([PackageSpec(; path) for path in (".",)])
Pkg.instantiate()
env:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
- name: Run the tests
if: matrix.version != 'nightly' || steps.setup_testutils.outcome == 'success'
continue-on-error: ${{ matrix.version == 'nightly' }}
id: run_tests
shell: julia --color=yes {0}
run: |
using Pkg
Pkg.test("EnzymeCore"; coverage=true)
- uses: julia-actions/julia-processcoverage@v1
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
directories: lib/EnzymeCore/src
- uses: codecov/codecov-action@v4
if: matrix.version != 'nightly' || steps.run_tests.outcome == 'success'
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false # or true if you want CI to fail when Codecov fails
integration:
name: Integration Tests - ${{ matrix.test }}
runs-on: ${{ matrix.os }}
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
*.jl.cov
*.jl.mem
/Manifest.toml
lib/EnzymeCore/Manifest.toml
/Manifest-v*.toml
/test/Manifest.toml
/docs/Manifest.toml
Expand Down
27 changes: 27 additions & 0 deletions lib/EnzymeCore/test/misc.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Test
using EnzymeCore
import EnzymeCore.EnzymeRules: forward, has_frule_from_sig

g(x) = x ^ 2
function forward(config, ::Const{typeof(g)}, ::Type{<:Const}, x::Const)
return Const(g(x.val))
end

@test has_frule_from_sig(Base.signature_type(g, Tuple{Float64}))

f(;kwargs) = 1.0

function forward(config, ::Const{typeof(f)}, ::Type{<:Const}; kwargs...)
return Const(f(; kwargs...))
end

@test has_frule_from_sig(Base.signature_type(f, Tuple{}))

data = [1.0, 2.0, 3.0, 4.0]

d = @view data[2:end]
y = @view data[3:end]
@test_skip @test_throws AssertionError Duplicated(d, y)

@test_throws ErrorException Active(data)
@test_skip @test_throws ErrorException Active(d)
28 changes: 4 additions & 24 deletions lib/EnzymeCore/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,8 @@
using Test
using EnzymeCore

import EnzymeCore.EnzymeRules: forward, has_frule_from_sig

g(x) = x ^ 2
function forward(config, ::Const{typeof(g)}, ::Type{<:Const}, x::Const)
return Const(g(x.val))
end

@test has_frule_from_sig(Base.signature_type(g, Tuple{Float64}))

f(;kwargs) = 1.0

function forward(config, ::Const{typeof(f)}, ::Type{<:Const}; kwargs...)
return Const(f(; kwargs...))
@testset verbose = true "EnzymeCore" begin
@testset "Miscellaneous" begin
include("misc.jl")
end
end

@test has_frule_from_sig(Base.signature_type(f, Tuple{}))

data = [1.0, 2.0, 3.0, 4.0]

d = @view data[2:end]
y = @view data[3:end]
@test_throws ErrorException Duplicated(d, y)

@test_throws ErrorException Active(data)
@test_throws ErrorException Active(d)
Loading