Skip to content

Commit

Permalink
ci: adding testing with mac M1 (#2385)
Browse files Browse the repository at this point in the history
* adding tests for mac M1

* RelativeAverageSpectralError
	Expected: tensor(5114.6641)
	Got: tensor(5114.6636)

* mecab
* Apply suggestions from code review

(cherry picked from commit 4230cfe)
  • Loading branch information
Borda committed Mar 16, 2024
1 parent 6cef8b4 commit 11f0efb
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ jobs:
- { python-version: "3.10", os: "windows" } # todo: https://discuss.pytorch.org/t/numpy-is-not-available-error/146192
include:
- { python-version: "3.10", requires: "latest", os: "ubuntu-22.04" }
- { python-version: "3.10", requires: "latest", os: "macOS-14" } # M1 machine
env:
PYTORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
Expand Down
7 changes: 7 additions & 0 deletions .github/workflows/ci-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ jobs:
- "2.1.2"
- "2.2.1"
include:
# cover additional python nad PR combinations
- { os: "ubuntu-22.04", python-version: "3.8", pytorch-version: "1.13.1" }
- { os: "ubuntu-22.04", python-version: "3.10", pytorch-version: "2.0.1" }
- { os: "ubuntu-22.04", python-version: "3.10", pytorch-version: "2.2.1" }
- { os: "ubuntu-22.04", python-version: "3.11", pytorch-version: "2.2.1" }
# standard mac machine, not the M1
- { os: "macOS-12", python-version: "3.8", pytorch-version: "1.13.1" }
- { os: "macOS-12", python-version: "3.10", pytorch-version: "2.0.1" }
- { os: "macOS-12", python-version: "3.11", pytorch-version: "2.2.1" }
# using the ARM based M1 machine
- { os: "macOS-14", python-version: "3.10", pytorch-version: "2.0.1" }
- { os: "macOS-14", python-version: "3.11", pytorch-version: "2.2.1" }
# some windows
- { os: "windows-2022", python-version: "3.8", pytorch-version: "1.13.1" }
- { os: "windows-2022", python-version: "3.10", pytorch-version: "2.0.1" }
- { os: "windows-2022", python-version: "3.11", pytorch-version: "2.2.1" }
Expand All @@ -75,6 +81,7 @@ jobs:
if: ${{ runner.os == 'macOS' }}
run: |
echo 'UNITTEST_TIMEOUT=--timeout=75' >> $GITHUB_ENV
brew install mecab # https://github.com/coqui-ai/TTS/issues/1533#issuecomment-1338662303
brew install gcc libomp ffmpeg # https://github.com/pytorch/pytorch/issues/20030
- name: Setup Linux
if: ${{ runner.os == 'Linux' }}
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,6 @@ env:
pip install -e . -U -r requirements/_devel.txt

data:
python -c "from urllib.request import urlretrieve ; urlretrieve('https://pl-public-data.s3.amazonaws.com/metrics/data.zip', 'data.zip')"
pip install -q wget
python -m wget https://pl-public-data.s3.amazonaws.com/metrics/data.zip
unzip -o data.zip -d ./tests
2 changes: 1 addition & 1 deletion src/torchmetrics/functional/image/_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _relative_average_spectral_error(preds: Tensor, target: Tensor, window_size:
>>> preds = torch.rand(4, 3, 16, 16, generator=gen)
>>> target = torch.rand(4, 3, 16, 16, generator=gen)
>>> _relative_average_spectral_error(preds, target)
tensor(5114.6641)
tensor(5114.66...)
"""
_deprecated_root_import_func("relative_average_spectral_error", "image")
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/functional/image/rase.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def relative_average_spectral_error(preds: Tensor, target: Tensor, window_size:
>>> preds = torch.rand(4, 3, 16, 16)
>>> target = torch.rand(4, 3, 16, 16)
>>> relative_average_spectral_error(preds, target)
tensor(5114.6641)
tensor(5114.66...)
Raises:
ValueError: If ``window_size`` is not a positive integer.
Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/image/_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class _RelativeAverageSpectralError(RelativeAverageSpectralError):
>>> target = torch.rand(4, 3, 16, 16)
>>> rase = _RelativeAverageSpectralError()
>>> rase(preds, target)
tensor(5114.6641)
tensor(5114.66...)
"""

Expand Down
2 changes: 1 addition & 1 deletion src/torchmetrics/image/rase.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RelativeAverageSpectralError(Metric):
>>> target = torch.rand(4, 3, 16, 16)
>>> rase = RelativeAverageSpectralError()
>>> rase(preds, target)
tensor(5114.6641)
tensor(5114.66...)
Raises:
ValueError: If ``window_size`` is not a positive integer.
Expand Down
8 changes: 4 additions & 4 deletions tests/unittests/audio/test_pesq.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def test_on_real_audio():
"""Test that metric works as expected on real audio signals."""
rate, ref = wavfile.read(_SAMPLE_AUDIO_SPEECH)
rate, deg = wavfile.read(_SAMPLE_AUDIO_SPEECH_BAB_DB)
pesq = perceptual_evaluation_speech_quality(torch.from_numpy(deg), torch.from_numpy(ref), rate, "wb")
assert pesq == 1.0832337141036987
pesq = perceptual_evaluation_speech_quality(torch.from_numpy(deg), torch.from_numpy(ref), rate, "nb")
assert pesq == 1.6072081327438354
pesq_score = perceptual_evaluation_speech_quality(torch.from_numpy(deg), torch.from_numpy(ref), rate, "wb")
assert torch.allclose(pesq_score, torch.tensor(1.0832337141036987), atol=1e-4)
pesq_score = perceptual_evaluation_speech_quality(torch.from_numpy(deg), torch.from_numpy(ref), rate, "nb")
assert torch.allclose(pesq_score, torch.tensor(1.6072081327438354), atol=1e-4)

0 comments on commit 11f0efb

Please sign in to comment.