Skip to content

Commit

Permalink
chore(ci): test gpu backend on ci (#75)
Browse files Browse the repository at this point in the history
* chore(ci): test gpu backend on ci

Signed-off-by: Cocoa <[email protected]>
  • Loading branch information
cocoa-xu authored Feb 18, 2025
1 parent bd60991 commit 0bf7e72
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ jobs:
- { otp: "25.3.2.15", elixir: "1.15.4" }
- { otp: "25.3.2.15", elixir: "1.16.2", lint: true }
- { otp: "25.3.2.15", elixir: "1.16.2", build: true }
- { otp: "25.3.2.15", elixir: "1.16.2", gpu: true }
- { otp: "25.3.2.15", elixir: "1.16.2", gpu: true, build: true }
env:
MIX_ENV: test
steps:
Expand Down Expand Up @@ -142,7 +144,14 @@ jobs:
- name: Run tests
run: |
export PATH="${{ steps.setup.outputs.path }}:${PATH}"
export EMLX_TEST_DEFAULT_GPU="${{ matrix.job.gpu }}"
if [ "${{ matrix.job.build }}" = "true" ]; then
export LIBMLX_BUILD=true
fi
mix test --warnings-as-errors
if [ "${{ matrix.job.gpu }}" = "true" ]; then
find test -name "*_test.exs" -exec bash -c 'NAME={}; echo -e "\n\n----$NAME----\n"; mix test $NAME' \;
else
mix test --warnings-as-errors
fi
15 changes: 14 additions & 1 deletion test/test_helper.exs
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
Application.put_env(:nx, :default_backend, EMLX.Backend)
backend =
if String.downcase(System.get_env("EMLX_TEST_DEFAULT_GPU", "false")) in [
"1",
"true",
"yes",
"t",
"y"
] do
{EMLX.Backend, device: :gpu}
else
EMLX.Backend
end

Application.put_env(:nx, :default_backend, backend)

ExUnit.start()

0 comments on commit 0bf7e72

Please sign in to comment.