Skip to content

Commit 0bf7e72

Browse files
authored
chore(ci): test gpu backend on ci (#75)
* chore(ci): test gpu backend on ci Signed-off-by: Cocoa <[email protected]>
1 parent bd60991 commit 0bf7e72

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

.github/workflows/ci.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ jobs:
7676
- { otp: "25.3.2.15", elixir: "1.15.4" }
7777
- { otp: "25.3.2.15", elixir: "1.16.2", lint: true }
7878
- { otp: "25.3.2.15", elixir: "1.16.2", build: true }
79+
- { otp: "25.3.2.15", elixir: "1.16.2", gpu: true }
80+
- { otp: "25.3.2.15", elixir: "1.16.2", gpu: true, build: true }
7981
env:
8082
MIX_ENV: test
8183
steps:
@@ -142,7 +144,14 @@ jobs:
142144
- name: Run tests
143145
run: |
144146
export PATH="${{ steps.setup.outputs.path }}:${PATH}"
147+
export EMLX_TEST_DEFAULT_GPU="${{ matrix.job.gpu }}"
148+
145149
if [ "${{ matrix.job.build }}" = "true" ]; then
146150
export LIBMLX_BUILD=true
147151
fi
148-
mix test --warnings-as-errors
152+
153+
if [ "${{ matrix.job.gpu }}" = "true" ]; then
154+
find test -name "*_test.exs" -exec bash -c 'NAME={}; echo -e "\n\n----$NAME----\n"; mix test $NAME' \;
155+
else
156+
mix test --warnings-as-errors
157+
fi

test/test_helper.exs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,16 @@
1-
Application.put_env(:nx, :default_backend, EMLX.Backend)
1+
backend =
2+
if String.downcase(System.get_env("EMLX_TEST_DEFAULT_GPU", "false")) in [
3+
"1",
4+
"true",
5+
"yes",
6+
"t",
7+
"y"
8+
] do
9+
{EMLX.Backend, device: :gpu}
10+
else
11+
EMLX.Backend
12+
end
13+
14+
Application.put_env(:nx, :default_backend, backend)
215

316
ExUnit.start()

0 commit comments

Comments
 (0)