-
Notifications
You must be signed in to change notification settings - Fork 643
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add istft operation #2029
base: main
Are you sure you want to change the base?
Add istft operation #2029
Conversation
coremltools/converters/mil/frontend/torch/test/test_torch_ops.py
Outdated
Show resolved
Hide resolved
coremltools/converters/mil/frontend/torch/test/test_torch_ops.py
Outdated
Show resolved
Hide resolved
[None, 60], # length | ||
) | ||
) | ||
def test_istft(self, compute_unit, backend, input_shape, complex, n_fft, hop_length, win_length, window, center, pad_mode, normalized, onesided): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is great with comprehensive coverages! Besides this, as istft
is the inverse of stft
, I'm wondering if it's possible to add another test case, where the torch model first call torch.stft
, and then feed the output back to torch.istft
to restore the original input?
coremltools/converters/mil/mil/passes/defs/lower_complex_dialect_ops.py
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contributions! Left some comments.
Maybe it's because that this PR is still in draft stage (I noticed the Draft
in PR title), but just want to mention that there are some undefined vars which triggers flake8 checking error: https://gitlab.com/coremltools1/coremltools/-/jobs/5539997442.
2495a5b
to
1aaed1c
Compare
This should be fixed now. |
I still don't understand how you handle the We should also handle it in the ISTFT in a similar manner. |
@alealv That's a really good question. As shown in STFT PyTorch doc, the More specifically, when we lower the STFT op in STFT lowering function, the |
I finally fixed all issues and tests pass. The only result I found weird is here elif length and return_complex:
with pytest.raises(ValueError, match="New var type `<class 'coremltools.converters.mil.mil.types.type_tensor.tensor.<locals>.tensor'>` not a subtype of existing var type `<class 'coremltools.converters.mil.mil.types.type_tensor.tensor.<locals>.tensor'>`"):
TorchBaseTest.run_compare_torch(
input_shape,
ISTFTModel(),
backend=backend,
compute_unit=compute_unit
) |
@alealv - did you forget to |
|
Your most recent commit is not the issue. The issue is that your first commit (950b1a0) is committed on top of a If we were to merge your changes, they would get committed on top of the current tip of You basically need to do three things: |
Sorry, I was rebasing over |
This is better. However it's still not right. The most recent commit your branch has from |
It's due to that the author's repo |
I hope now is correct. For some reason I had |
You're branch looks good now. Thanks. Here is the CI run: |
hmmm, CI is failing con functions I didn't touch. |
I've dived deep into the CI error.
def test_spectrogram(self, compute_unit, backend, input_shape, spec, power):
if platform.machine() != "arm64":
pytest.xfail(
"rdar://108001659 ([PyTorch] Torchaudio Spectrogram Failed on Intel Machine)"
)
Taking a closer look, if My last commit should do the trick. Also, I couldn't find any of the runs of |
When the Spectrogram was implemented, there was a quite strange failure on Intel Machine, and the M chip Machine works fine. We marked it as xfail while we are debugging it.
Great investigations! Thanks!
Great catch! It's due to that test is marked by Also, kicked off another CI with your latest commit: https://gitlab.com/coremltools1/coremltools/-/pipelines/1133907719 |
@alealv Just want to check if you have run the tests locally on your machine? The
To be safer, let me remove those |
Yes, all test pass in my Intel machine Results (28832.46s (8:00:32)):
21240 passed
11160 skipped That's for the whole |
Nice! In the most recent run after removing the pytest.slow deco, the M-chip Mac tests failed for iSTFT: https://gitlab.com/coremltools1/coremltools/-/pipelines/1134078191 |
The And for the other test_py310_pytorch unfortunately I cannot reproduce. I ran specifically for the first test case that fails _ TestSTFT.test_istft[compute_unit=ComputeUnit.CPU_ONLY-backend=('mlprogram', 'fp16')-channels=None-n_fft=16-num_frames=5-hop_length=None-win_length=None-window=None-center=False-normalized=False-onesided=None-length=None-return_complex=False] _ and got Results (6.42s):
1 passed so I guess it's something is done very differently on ARM machines. |
Thank you for trying to reproduce it on your side! Yeah there are a lot of things could lead to different behaviors (OS version, Sys Arch of Intel/ARM, etc). Let me rerun it on CI. |
This is really great work. Any updates on getting this merged? |
We just upgraded our CI machine recently, which hopefully should get rid of those intel-machine-specific issues. @alealv Could you rebase/merge with the latest head? Then I can help to mark tests as xfail for intel (if it still failed) and merge this PR. Thank you so much for your great contributions! |
Close #2016
This code adds ISTFT op
It was a bit challenging to go through it because I needed to learn available
mil
operations and adapt the process.I based my self on this PR as suggested by junepiz
There are still many things I'm not confident with and I would like some help if possible:
STFT
doesn't usecenter
. The same would apply toISTFT
for loop
in the OLA (overlap-add) function is fine or I need to use some special computation