Skip to content

Commit b6ee968

Browse files
feat: support conditionals (#185)
* feat: support conditionals * chore: run formatter * feat: run post-processing on the expression to avoid boxing * feat: overload traced_if for Reactant types * fix: incorrect region * fix: use `stablehlo.return_` * feat: use ExpressionsExplorer for parsing * fix: replace args * feat: compiling `if-else` blocks now work 🎉 * feat: compile scalars in branches * fix: bug in unrolling the generated code * feat: support elseif * feat: introduce a `MissingTracedValue` * feat: cleanup missing values from the IR * chore: apply formatting suggestion Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: codegen for else statements * refactor: move code to ReactantCore * chore: add to authors list * test: test if conditions * fix: check for elseif instead of not if * chore: apply suggestions from code review Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * ci(buildkite): fix the workflow * test: more test cases * fix: nested if handling * fix: partial fix to mutation issue * fix: code generation * docs: rename to type instability * test: mark some tests as broken --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent babeb7c commit b6ee968

File tree

16 files changed

+1082
-29
lines changed

16 files changed

+1082
-29
lines changed

.buildkite/pipeline.yml

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,20 @@ steps:
1010
plugins:
1111
- JuliaCI/julia#v1:
1212
version: "{{matrix.version}}"
13-
- JuliaCI/julia-test#v1:
14-
test_args: "--gpu"
1513
- JuliaCI/julia-coverage#v1:
1614
codecov: true
1715
dirs:
1816
- src
1917
- ext
18+
- lib/ReactantCore/src
19+
commands: |
20+
julia --project=. -e 'println("--- :julia: Instantiating project")
21+
using Pkg
22+
Pkg.develop([PackageSpec(path="lib/ReactantCore")])'
23+
24+
julia --project=. -e 'println("--- :julia: Run Tests")
25+
using Pkg
26+
Pkg.test(; coverage="user")'
2027
agents:
2128
queue: "juliagpu"
2229
cuda: "*"
@@ -34,7 +41,7 @@ steps:
3441
command: |
3542
julia --project=benchmark -e 'println("--- :julia: Instantiating project")
3643
using Pkg
37-
Pkg.develop([PackageSpec(path=pwd())])'
44+
Pkg.develop([PackageSpec(path=pwd()), PackageSpec(path="lib/ReactantCore")])'
3845
3946
julia --project=benchmark -e 'println("--- :julia: Run Benchmarks")
4047
include("benchmark/runbenchmarks.jl")'
@@ -59,7 +66,7 @@ steps:
5966
command: |
6067
julia --project=benchmark -e 'println("--- :julia: Instantiating project")
6168
using Pkg
62-
Pkg.develop([PackageSpec(path=pwd())])'
69+
Pkg.develop([PackageSpec(path=pwd()), PackageSpec(path="lib/ReactantCore")])'
6370
6471
julia --project=benchmark -e 'println("--- :julia: Run Benchmarks")
6572
include("benchmark/runbenchmarks.jl")'

.github/workflows/CI.yml

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,19 @@ jobs:
8484
julia --color=yes --project=deps -e 'using Pkg; Pkg.instantiate()'
8585
SDKROOT=`xcrun --show-sdk-path` julia --color=yes --project=deps deps/build_local.jl
8686
cp LocalPreferences.toml test/
87-
- uses: julia-actions/julia-runtest@v1
88-
# if: steps.buildpkg.outcome == 'success'
87+
- name: "Install Dependencies and Run Tests"
88+
run: |
89+
import Pkg
90+
Pkg.Registry.update()
91+
# Install packages present in subdirectories
92+
dev_pks = Pkg.PackageSpec[]
93+
for path in ("lib/ReactantCore",)
94+
push!(dev_pks, Pkg.PackageSpec(; path))
95+
end
96+
Pkg.develop(dev_pks)
97+
Pkg.instantiate()
98+
Pkg.test(; coverage="user")
99+
shell: julia --color=yes --code-coverage=user --depwarn=yes --project=. {0}
89100
id: run_tests
90101
env:
91102
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager
@@ -108,7 +119,11 @@ jobs:
108119
- run: |
109120
julia --color=yes --project=docs -e '
110121
using Pkg
111-
Pkg.develop([PackageSpec(path=pwd()), PackageSpec("Reactant_jll")])
122+
Pkg.develop([
123+
PackageSpec(path=pwd()),
124+
PackageSpec("Reactant_jll"),
125+
PackageSpec(path="lib/ReactantCore")
126+
])
112127
Pkg.instantiate()'
113128
env:
114129
JULIA_PKG_SERVER_REGISTRY_PREFERENCE: eager

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ dist/
8181
downloads/
8282
eggs/
8383
.eggs/
84-
lib/
8584
lib64/
8685
parts/
8786
sdist/

Project.toml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "Reactant"
22
uuid = "3c362404-f566-11ee-1572-e11a4b42c853"
3-
authors = ["William Moses <[email protected]>", "Valentin Churavy <[email protected]>", "Sergio Sánchez Ramírez <[email protected]>", "Paul Berg <[email protected]>"]
3+
authors = ["William Moses <[email protected]>", "Valentin Churavy <[email protected]>", "Sergio Sánchez Ramírez <[email protected]>", "Paul Berg <[email protected]>", "Avik Pal <[email protected]>"]
44
version = "0.2.3"
55

66
[deps]
@@ -11,6 +11,7 @@ Enzyme = "7da242da-08ed-463a-9acd-ee780be4f1d9"
1111
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
1212
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
1313
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
14+
ReactantCore = "a3311ec8-5e00-46d5-b541-4f83e724a433"
1415
Reactant_jll = "0192cb87-2b54-54ad-80e0-3be72ad8a3c0"
1516
Scratch = "6c6a2e73-6563-6170-7368-637461726353"
1617

@@ -33,6 +34,7 @@ Enzyme = "0.13"
3334
NNlib = "0.9"
3435
OrderedCollections = "1"
3536
Preferences = "1.4"
37+
ReactantCore = "0.1"
3638
Reactant_jll = "0.0.22"
3739
Scratch = "1.2"
3840
Statistics = "1.10"

lib/ReactantCore/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2024 Enzyme Automatic Differentiation Compiler
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

lib/ReactantCore/Project.toml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
name = "ReactantCore"
2+
uuid = "a3311ec8-5e00-46d5-b541-4f83e724a433"
3+
authors = ["William Moses <[email protected]>", "Valentin Churavy <[email protected]>", "Sergio Sánchez Ramírez <[email protected]>", "Paul Berg <[email protected]>", "Avik Pal <[email protected]>"]
4+
version = "0.1.0"
5+
6+
[deps]
7+
ExpressionExplorer = "21656369-7473-754a-2065-74616d696c43"
8+
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
9+
10+
[compat]
11+
ExpressionExplorer = "1"
12+
MacroTools = "0.5.13"
13+
julia = "1.10"

0 commit comments

Comments
 (0)