Skip to content

Commit

Permalink
Add testing infra
Browse files Browse the repository at this point in the history
  • Loading branch information
wsmoses committed Apr 14, 2024
1 parent e132afd commit 3858cee
Show file tree
Hide file tree
Showing 6 changed files with 176 additions and 12 deletions.
164 changes: 164 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
name: CI
on:
pull_request:
push:
branches:
- main
- release-*
tags: '*'

concurrency:
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ matrix.libReactant }} libReactant - assertions=${{ matrix.assertions }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.9'
- '1.10'
- 'nightly'
os:
- ubuntu-20.04
- macOS-latest
- windows-latest
arch:
- x64
assertions:
- false
libReactant: [local, packaged]
exclude:
- os: windows-latest
arch: x64
libReactant: local
include:
- os: ubuntu-20.04
arch: x86
libReactant: packaged
version: '1.6'
assertions: false
- os: ubuntu-20.04
arch: x86
libReactant: packaged
version: '1.7'
assertions: false
- os: ubuntu-20.04
arch: x86
libReactant: packaged
version: '1.8'
assertions: false
- os: ubuntu-20.04
arch: x86
libReactant: packaged
version: '1.9'
assertions: false
- os: ubuntu-20.04
arch: x86
libReactant: packaged
version: '1.10'
assertions: false
- os: ubuntu-20.04
arch: x64
libReactant: packaged
version: '1.7'
assertions: true
- os: ubuntu-20.04
arch: x64
libReactant: packaged
version: '1.8'
assertions: true
- os: ubuntu-20.04
arch: x64
libReactant: packaged
version: '1.9'
assertions: true
- os: ubuntu-20.04
arch: x64
libReactant: packaged
version: '1.10'
assertions: true
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
if: ${{ ! matrix.assertions }}
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/checkout@v3
if: ${{ matrix.assertions }}
with:
repository: 'JuliaLang/julia'
ref: release-${{ matrix.version }}
path: 'julia'
- name: Compile Julia
if: ${{ matrix.assertions }}
run: |
sed -i.bak 's/exit 2/exit 0/g' julia/deps/tools/jlchecksum
make -C julia -j $(nproc) FORCE_ASSERTIONS=1 LLVM_ASSERTIONS=1 JULIA_PRECOMPILE=0
echo $PWD/julia/usr/bin >> $GITHUB_PATH
- uses: actions/cache@v1
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: Build libReactant
if: ${{ matrix.libReactant == 'local' && matrix.os != 'macOS-latest'}}
id: build_libreactant
run: |
julia --project=deps -e 'using Pkg; Pkg.instantiate()'
julia --project=deps deps/build_local.jl
cp LocalPreferences.toml test/
- name: Build libReactant MacOS
if: ${{ matrix.libReactant == 'local' && matrix.os == 'macOS-latest'}}
id: build_libreactant_mac
run: |
julia --project=deps -e 'using Pkg; Pkg.instantiate()'
SDKROOT=`xcrun --show-sdk-path` julia --project=deps deps/build_local.jl
cp LocalPreferences.toml test/
- uses: julia-actions/julia-runtest@v1
if: steps.buildpkg.outcome == 'success'
id: run_tests
env:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
- uses: julia-actions/julia-processcoverage@v1
if: steps.run_tests.outcome == 'success'
- uses: codecov/codecov-action@v1
if: steps.run_tests.outcome == 'success'
with:
file: lcov.info
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop([PackageSpec(path=pwd())])
Pkg.instantiate()'
env:
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
- run: |
julia --project=docs -e '
using Documenter: DocMeta, doctest
using Reactant
DocMeta.setdocmeta!(Reactant, :DocTestSetup, :(using Reactant); recursive=true)
doctest(Reactant)'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
3 changes: 1 addition & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@ version = "0.1.0"
[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
JLLWrappers = "692b3bcd-3c85-4b1f-b108-f13ce0eb3210"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Reactant_jll = "0192cb87-2b54-54ad-80e0-3be72ad8a3c0"

[weakdeps]
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
Expand Down
4 changes: 3 additions & 1 deletion src/mlir/Dialects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ module Dialects
import ..IR: Attribute, NamedAttribute, context
import ..API

using Reactant_jll

namedattribute(name, val) = namedattribute(name, Attribute(val))
namedattribute(name, val::Attribute) = NamedAttribute(name, val)
function namedattribute(name, val::NamedAttribute)
Expand All @@ -12,7 +14,7 @@ end

operandsegmentsizes(segments) = namedattribute("operand_segment_sizes", Attribute(Int32.(segments)))

for path in readdir(joinpath(@__DIR__, "../../deps/ReactantExtra/bazel-bin"); join=true)
for path in readdir(Reactant_jll.artifact_dir; join=true)
if endswith("inc.jl")(path)
include(path)
end
Expand Down
Binary file removed src/mlir/IR/.Value.jl.swp
Binary file not shown.
7 changes: 3 additions & 4 deletions src/mlir/MLIR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@ module MLIR

module API
using CEnum
using JLLWrappers
using Preferences
using Libdl
using Reactant_jll

const mlir_c = joinpath(@__DIR__, "../../deps/ReactantExtra/bazel-bin/libReactantExtra.so")
const mlir_c = Reactant_jll.libReactantExtra

# MLIR C API
let
include(joinpath(@__DIR__, "../../deps/ReactantExtra/bazel-bin/libMLIR_h.jl"))
include("libMLIR_h.jl")
end
end # module API

Expand Down
10 changes: 5 additions & 5 deletions test/bcast.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ end


mutable struct Data
v::(Reactant.TracedRArray{Float64, S,1} where S)
v::(Reactant.TracedRArray{Float64, S,2} where S)
end
@noinline function tmp(a, b, d)
@show d
Expand All @@ -34,7 +34,7 @@ function test()
mod = MLIR.IR.Module(MLIR.IR.Location())
modbody = MLIR.IR.body(mod)

in_tys = [MLIR.IR.TensorType([3], MLIR.IR.Type(Float64))]
in_tys = [MLIR.IR.TensorType([2,2], MLIR.IR.Type(Float64))]

func = MLIR.Dialects.func.func_(; sym_name="main_tmp", function_type=MLIR.IR.FunctionType(in_tys, []), body=MLIR.IR.Region())

Expand All @@ -45,8 +45,8 @@ function test()

GC.@preserve mod func fnbody begin
MLIR.IR.block!(fnbody) do
a = ones(4)
b = ones(4)
a = ones(2,2)
b = ones(2,2)
d = Data(Reactant.TracedRArray{Float64, (2,2),2}((), MLIR.IR.argument(fnbody, 1)))

tmp(a, b, d)
Expand All @@ -56,4 +56,4 @@ function test()
println(string(mod))
end
end
test()
test()

0 comments on commit 3858cee

Please sign in to comment.