Skip to content

Commit de13de9

Browse files
committed
Debug forced align on cpu
1 parent f98415e commit de13de9

9 files changed

Lines changed: 42 additions & 45 deletions

File tree

.github/scripts/unittest-windows/run_test.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ env | grep TORCHAUDIO || true
1313

1414
cd test
1515
if [ -z "${CUDA_VERSION:-}" ] ; then
16-
pytest --continue-on-collection-errors --cov=torchaudio --junitxml=${RUNNER_TEST_RESULTS_DIR}/junit.xml -v --durations 20 torchaudio_unittest -k "not fairseq and not demucs and not librosa"
16+
pytest -sv --continue-on-collection-errors --cov=torchaudio --junitxml=${RUNNER_TEST_RESULTS_DIR}/junit.xml -v --durations 20 torchaudio_unittest -k "not fairseq and not demucs and not librosa"
1717
else
18-
pytest --continue-on-collection-errors --cov=torchaudio --junitxml=${RUNNER_TEST_RESULTS_DIR}/junit.xml -v --durations 20 torchaudio_unittest -k "not cpu and (cuda or gpu) and not fairseq and not demucs and not librosa"
18+
pytest -sv --continue-on-collection-errors --cov=torchaudio --junitxml=${RUNNER_TEST_RESULTS_DIR}/junit.xml -v --durations 20 torchaudio_unittest -k "not cpu and (cuda or gpu) and not fairseq and not demucs and not librosa"
1919
fi
2020
coverage html

.github/workflows/unittest-linux-cpu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
export FFMPEG_VERSION="${{ matrix.ffmpeg-version }}"
3636
export PIP_PROGRESS_BAR=off
3737
export CONDA_QUIET=1
38+
export NO_COLOR=1
3839
3940
# Set UPLOAD_CHANNEL
4041
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then

.github/workflows/unittest-linux-gpu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ jobs:
3737
export CU_VERSION_WITHOUT_PERIODS="$(echo "${{ matrix.cuda-version }}" | sed 's/\.//g')"
3838
export PIP_PROGRESS_BAR=off
3939
export CONDA_QUIET=1
40+
export NO_COLOR=1
4041
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_CUDA_SMALL_MEMORY=true
4142
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_ON_PYTHON_310=true
4243
export TORCHAUDIO_TEST_ALLOW_SKIP_IF_TEMPORARY_DISABLED=true

.github/workflows/unittest-macos-cpu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ jobs:
3636
export CONDA_QUIET=1
3737
export CU_VERSION=""
3838
export USE_OPENMP="0"
39+
export NO_COLOR=1
3940
4041
# Set CHANNEL
4142
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then

.github/workflows/unittest-windows-cpu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ jobs:
2525
export PIP_PROGRESS_BAR=off
2626
export CONDA_QUIET=1
2727
unset CUDA_VERSION
28+
export NO_COLOR=1
2829
2930
# Set CHANNEL
3031
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then

.github/workflows/unittest-windows-gpu.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
export CONDA_QUIET=1
2828
export USE_CUDA=1
2929
export CUBLAS_WORKSPACE_CONFIG=:4096:8
30+
export NO_COLOR=1
3031
3132
# Set CHANNEL
3233
if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then

src/libtorchaudio/forced_align/cpu/compute.cpp

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include <torch/csrc/stable/tensor.h>
66
#include <torch/headeronly/core/Dispatch_v2.h>
77
#include <torch/headeronly/core/ScalarType.h>
8-
8+
#include <iostream>
99
namespace torchaudio {
1010
namespace alignment {
1111
namespace cpu {
@@ -21,6 +21,8 @@ void forced_align_impl(
2121
const Tensor& targets,
2222
const int64_t blank,
2323
Tensor& paths) {
24+
std::cout << "ENTERING forced_align_impl: " << target_scalar_type
25+
<< std::endl;
2426
const scalar_t kNegInfinity = -std::numeric_limits<scalar_t>::infinity();
2527
using target_t = typename std::
2628
conditional<target_scalar_type == ScalarType::Int, int, int64_t>::type;
@@ -153,22 +155,26 @@ std::tuple<Tensor, Tensor> compute(
153155
Tensor inputLengths,
154156
Tensor targetLengths,
155157
const int64_t blank) {
158+
std::cout << "compute:1" << std::endl;
156159
STD_TORCH_CHECK(logProbs.is_cpu(), "log_probs must be a CPU tensor");
157160
STD_TORCH_CHECK(targets.is_cpu(), "targets must be a CPU tensor");
158161
STD_TORCH_CHECK(inputLengths.is_cpu(), "input_lengths must be a CPU tensor");
159162
STD_TORCH_CHECK(
160163
targetLengths.is_cpu(), "target_lengths must be a CPU tensor");
164+
std::cout << "compute:2" << std::endl;
161165
STD_TORCH_CHECK(
162166
logProbs.scalar_type() == ScalarType::Double ||
163167
logProbs.scalar_type() == ScalarType::Float ||
164168
logProbs.scalar_type() == ScalarType::Half,
165169
"log_probs must be float64, float32 or float16 (half) type");
170+
std::cout << "compute:3" << std::endl;
166171
STD_TORCH_CHECK(
167172
targets.scalar_type() == ScalarType::Int ||
168173
targets.scalar_type() == ScalarType::Long,
169174
"targets must be int32 or int64 type");
170175
STD_TORCH_CHECK(logProbs.is_contiguous(), "log_probs must be contiguous");
171176
STD_TORCH_CHECK(targets.is_contiguous(), "targets must be contiguous");
177+
std::cout << "compute:4" << std::endl;
172178
STD_TORCH_CHECK(
173179
logProbs.dim() == 3,
174180
"log_probs must be 3-D (batch_size, input length, num classes)");
@@ -178,37 +184,52 @@ std::tuple<Tensor, Tensor> compute(
178184
inputLengths.dim() == 1, "input_lengths must be 1-D (batch_size,)");
179185
STD_TORCH_CHECK(
180186
targetLengths.dim() == 1, "target_lengths must be 1-D (batch_size,)");
187+
std::cout << "compute:5" << std::endl;
181188
STD_TORCH_CHECK(
182189
logProbs.size(0) == 1,
183-
"The batch dimension for log_probs must be 1 at the current version.")
190+
"The batch dimension for log_probs must be 1 at the current version.");
184191
STD_TORCH_CHECK(
185192
targets.size(0) == 1,
186-
"The batch dimension for targets must be 1 at the current version.")
193+
"The batch dimension for targets must be 1 at the current version.");
194+
std::cout << "compute:6" << std::endl;
187195
STD_TORCH_CHECK(
188196
blank >= 0 && blank < logProbs.size(-1),
189197
"blank must be within [0, num classes)");
198+
std::cout << "compute:7" << std::endl;
190199
STD_TORCH_CHECK(
191200
logProbs.size(1) == torchaudio::util::max<int64_t>(inputLengths),
192201
"input length mismatch");
202+
std::cout << "compute:8" << std::endl;
193203
STD_TORCH_CHECK(
194204
targets.size(1) == torchaudio::util::max<int64_t>(targetLengths),
195205
"target length mismatch");
206+
std::cout << "compute:9" << std::endl;
196207
const auto B = logProbs.size(0);
197208
const auto T = logProbs.size(1);
209+
std::cout << "compute:10" << std::endl;
198210
Tensor paths = torch::stable::empty({B, T}, targets.scalar_type());
211+
std::cout << "compute:11" << std::endl;
199212
torch::stable::zero_(paths);
213+
std::cout << "compute:12" << std::endl;
200214
THO_DISPATCH_V2(
201215
logProbs.scalar_type(),
202216
"forced_align_impl",
203217
AT_WRAP([&] {
218+
std::cout << "compute:13" << std::endl;
204219
if (targets.scalar_type() == ScalarType::Long) {
220+
std::cout << "compute:14" << std::endl;
205221
forced_align_long_impl<scalar_t>(logProbs, targets, blank, paths);
206-
} else {
222+
} else if (targets.scalar_type() == ScalarType::Int) {
223+
std::cout << "compute:15" << std::endl;
207224
forced_align_int_impl<scalar_t>(logProbs, targets, blank, paths);
225+
} else {
226+
STD_TORCH_CHECK(
227+
false, "unexpected targets dtype:", targets.scalar_type());
208228
}
209229
}),
210230
AT_EXPAND(AT_FLOATING_TYPES),
211231
ScalarType::Half);
232+
std::cout << "compute:16" << std::endl;
212233
return std::make_tuple(paths, logProbs);
213234
}
214235

src/torchaudio/functional/_alignment.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,17 @@ def forced_align(
6969
assert input_lengths is not None
7070
assert target_lengths is not None
7171

72+
def _show(t):
73+
return f"{t.shape=} {t.dtype=} {t.device=}"
74+
75+
print(f"{_show(log_probs)=}")
76+
print(f"{_show(targets)=}")
77+
print(f"{_show(input_lengths)=}")
78+
print(f"{_show(target_lengths)=}")
79+
print(f"{blank=}", flush=True)
7280
paths, scores = torch.ops.torchaudio.forced_align(log_probs, targets, input_lengths, target_lengths, blank)
81+
print(f"{_show(paths)=}")
82+
print(f"{_show(scores)=}")
7383
return paths, scores[:, torch.arange(scores.shape[1]), paths[0]]
7484

7585

tools/setup_helpers/extension.py

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -50,45 +50,6 @@ def get_ext_fullpath(self, ext_name: str) -> str:
5050
print(f"XXXXXXXXXXXX get_ext_fullpath({ext_name}) -> {result}")
5151
return result
5252

53-
def _get_ext_filename(self, fullname: str) -> str:
54-
import inspect
55-
56-
import setuptools.command.build_ext as m
57-
58-
orig = inspect.getsource(super().get_ext_filename)
59-
print("AAAAAAAAAAAAAAAAAAAAA")
60-
print(f"{orig}")
61-
print("AAAAAAAAAAAAAAAAAAAAA")
62-
print(f"OOOOOOOOOOOOOOOOOO {super().get_ext_filename(fullname)=}")
63-
64-
_build_ext = m._build_ext
65-
so_ext = os.getenv("SETUPTOOLS_EXT_SUFFIX")
66-
if so_ext:
67-
filename = os.path.join(*fullname.split(".")) + so_ext
68-
else:
69-
filename = _build_ext.get_ext_filename(self, fullname)
70-
ext_suffix = m.get_config_var("EXT_SUFFIX")
71-
if not isinstance(ext_suffix, str):
72-
raise OSError(
73-
"Configuration variable EXT_SUFFIX not found for this platform "
74-
"and environment variable SETUPTOOLS_EXT_SUFFIX is missing"
75-
)
76-
so_ext = ext_suffix
77-
78-
if fullname in self.ext_map:
79-
ext = self.ext_map[fullname]
80-
abi3_suffix = m.get_abi3_suffix()
81-
if ext.py_limited_api and abi3_suffix: # Use abi3
82-
filename = filename[: -len(so_ext)] + abi3_suffix
83-
if isinstance(ext, m.Library):
84-
fn, ext = os.path.splitext(filename)
85-
filename = self.shlib_compiler.library_filename(fn, m.libtype)
86-
elif m.use_stubs and ext._links_to_dynamic:
87-
d, fn = os.path.split(filename)
88-
filename = os.path.join(d, "dl-" + fn)
89-
print(f"YYYYYYYYYYYYYYYYYYYYYYY {filename=}")
90-
return filename
91-
9253
def get_ext_filename(self, ext_name):
9354
# Origin: torch/utils/cpp_extension.py
9455
# Fixes a bug: don't try to remove ABI part that does not

0 commit comments

Comments
 (0)