Skip to content

Commit 11560ef

Browse files
committed
Merge branch 'main' into remove_libtorio
2 parents 3e6cd31 + bdd9c72 commit 11560ef

File tree

7 files changed

+28
-44
lines changed

7 files changed

+28
-44
lines changed

.github/workflows/build_docs.yml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,6 @@ jobs:
5959
6060
echo "::endgroup::"
6161
echo "::group::Install PyTorch"
62-
# conda install \
63-
# --yes \
64-
# --quiet \
65-
# -c "pytorch-${CHANNEL}" \
66-
# -c nvidia "pytorch-${CHANNEL}"::pytorch[build="*${CU_VERSION}*"] \
67-
# "${CUDATOOLKIT}"
6862
6963
GPU_ARCH_ID=cu126 # This is hard-coded and must be consistent with gpu-arch-version.
7064
PYTORCH_WHEEL_INDEX="https://download.pytorch.org/whl/${CHANNEL}/${GPU_ARCH_ID}"
@@ -75,19 +69,15 @@ jobs:
7569
conda install --quiet --yes cmake>=3.18.0 ninja
7670
pip3 install --progress-bar off -v -e . --no-use-pep517
7771
72+
# TODO: Need to rely on torchcodec instead of building ffmpeg from source.
7873
echo "::endgroup::"
7974
echo "::group::Build FFmpeg"
8075
.github/scripts/ffmpeg/build_gpu.sh
8176
8277
echo "::endgroup::"
8378
echo "::group::Install other dependencies"
84-
conda install \
85-
--quiet --yes \
86-
-c conda-forge \
87-
sox libvorbis pandoc doxygen pysoundfile
88-
pip install --progress-bar off \
89-
git+https://github.com/kpu/kenlm/ flashlight-text \
90-
-r docs/requirements.txt -r docs/requirements-tutorials.txt
79+
80+
pip install --progress-bar off -r docs/requirements.txt -r docs/requirements-tutorials.txt
9181
9282
echo "::endgroup::"
9383
echo "::group::Build documentation"

docs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ docset: html
2424
# Catch-all target: route all unknown targets to Sphinx using the new
2525
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
2626
%: Makefile
27-
doxygen source/Doxyfile
27+
# doxygen source/Doxyfile
2828
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
2929
@python post_process_dispatcher.py $(BUILDDIR)
3030

docs/requirements.txt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ Jinja2<3.1.0
22
matplotlib<=3.8
33
pyparsing<3,>=2.0.2
44

5-
# C++ docs
6-
breathe==4.34.0
7-
85
# Note:
96
# When changing Sphinx-related packages, make sure that the custom behaviors in the following
107
# locations are working as expected.
@@ -17,15 +14,3 @@ sphinxcontrib.katex==0.8.6
1714
sphinxcontrib.bibtex
1815
sphinx_gallery==0.11.1
1916
nbsphinx==0.8.8
20-
21-
# https://github.com/bmcfee/resampy/issues/106
22-
# Since 2022-07-07 build_docs CI job started to fail.
23-
# Pinning resampy to 0.2.2 resolves this.
24-
# The real cause is not know at the moment but the use
25-
# of librosa seems to cause this
26-
# https://github.com/bmcfee/resampy/issues/106
27-
# In our case, the tutorial timed out is online_asr_tutorial,
28-
# which itself does not use resampy
29-
# However audio_feature_augmentation_tutorial is executed before that,
30-
# which uses librosa.
31-
resampy==0.2.2

docs/source/conf.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,23 +53,13 @@
5353
"sphinxcontrib.bibtex",
5454
"sphinx_gallery.gen_gallery",
5555
"nbsphinx",
56-
"breathe",
5756
]
5857

59-
breathe_projects = {"libtorio": "cpp/xml"}
60-
61-
breathe_default_project = "libtorio"
62-
63-
breathe_projects_source = {
64-
"libtorio": (
65-
"../../src/libtorio/ffmpeg/",
66-
["stream_reader/stream_reader.h", "stream_writer/stream_writer.h"],
67-
)
68-
}
6958

7059
nbsphinx_requirejs_path = ""
7160

7261
autodoc_member_order = "bysource"
62+
autodoc_mock_imports = ['torchaudio.models.decoder']
7363

7464
# katex options
7565
#
@@ -121,7 +111,7 @@ def _get_pattern():
121111
}
122112

123113
ret = {"filename_pattern": "tutorial.py"}
124-
no_build = r"/examples/tutorials/asr_inference_with_cuda_ctc_decoder_tutorial.py"
114+
no_build = r".*ctc_decoder_tutorial.py"
125115
if os.getenv("GALLERY_PATTERN"):
126116
# See https://github.com/pytorch/tutorials/blob/cbf2238df0e78d84c15bd94288966d2f4b2e83ae/conf.py#L75-L83
127117
ret["ignore_pattern"] = r"(/(?!" + re.escape(os.getenv("GALLERY_PATTERN")) + r")[^/]+$)"

src/torchaudio/functional/functional.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,7 @@ def _get_mask_param(mask_param: int, p: float, axis_length: int) -> int:
817817
def mask_along_axis_iid(
818818
specgrams: Tensor,
819819
mask_param: int,
820-
mask_value: float,
820+
mask_value: Union[float, Tensor],
821821
axis: int,
822822
p: float = 1.0,
823823
) -> Tensor:
@@ -874,7 +874,12 @@ def mask_along_axis_iid(
874874

875875
# Per batch example masking
876876
specgrams = specgrams.transpose(axis, -1)
877-
specgrams = specgrams.masked_fill((mask >= mask_start) & (mask < mask_end), mask_value)
877+
# this aims to avoid CPU-GPU sync from upstream
878+
specgrams = (
879+
torch.where((mask >= mask_start) & (mask < mask_end), mask_value.repeat(*specgrams.shape), specgrams)
880+
if isinstance(mask_value, Tensor)
881+
else specgrams.masked_fill((mask >= mask_start) & (mask < mask_end), mask_value)
882+
)
878883
specgrams = specgrams.transpose(axis, -1)
879884

880885
return specgrams

src/torchaudio/transforms/_transforms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1185,7 +1185,7 @@ def __init__(self, mask_param: int, axis: int, iid_masks: bool, p: float = 1.0)
11851185
self.iid_masks = iid_masks
11861186
self.p = p
11871187

1188-
def forward(self, specgram: Tensor, mask_value: float = 0.0) -> Tensor:
1188+
def forward(self, specgram: Tensor, mask_value: Union[float, torch.Tensor] = 0.0) -> Tensor:
11891189
r"""
11901190
Args:
11911191
specgram (Tensor): Tensor of dimension `(..., freq, time)`.

test/torchaudio_unittest/functional/functional_impl.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,20 @@ def test_mask_along_axis_iid(self, mask_param, mask_value, axis, p):
456456
assert mask_specgrams.size() == specgrams.size()
457457
assert (num_masked_columns < mask_param).sum() == num_masked_columns.numel()
458458

459+
@parameterized.expand(list(itertools.product([100], [0.0, 30.0], [2, 3], [0.2, 1.0])))
460+
def test_mask_along_axis_iid_mask_value(self, mask_param, mask_value, axis, p):
461+
specgrams = torch.randn(4, 2, 1025, 400, dtype=self.dtype, device=self.device)
462+
mask_value_tensor = torch.tensor(mask_value, dtype=self.dtype, device=self.device)
463+
torch.manual_seed(0)
464+
# as this operation is random we need to fix the seed for results to match
465+
mask_specgrams = F.mask_along_axis_iid(specgrams, mask_param, mask_value_tensor, axis, p=p)
466+
torch.manual_seed(0)
467+
mask_specgrams_float = F.mask_along_axis_iid(specgrams, mask_param, mask_value, axis, p=p)
468+
assert torch.allclose(
469+
mask_specgrams, mask_specgrams_float
470+
), f"""Masking with float and tensor should be the same diff = {
471+
torch.abs(mask_specgrams - mask_specgrams_float).max()}"""
472+
459473
@parameterized.expand(list(itertools.product([(2, 1025, 400), (1, 201, 100)], [100], [0.0, 30.0], [1, 2])))
460474
def test_mask_along_axis_preserve(self, shape, mask_param, mask_value, axis):
461475
"""mask_along_axis should not alter original input Tensor

0 commit comments

Comments
 (0)