Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix '__floordiv__ is deprecated' warnings #4945

Merged
sw005320 merged 1 commit intoespnet:masterfrom
fujimotos:sf/floordiv
Feb 20, 2023
Merged

Fix '__floordiv__ is deprecated' warnings #4945
sw005320 merged 1 commit intoespnet:masterfrom
fujimotos:sf/floordiv

Conversation

@fujimotos
Copy link
Contributor

When we do this with torch >= 0.12.1:

speech2text = Speech2Text(...)

PyTorch emits a couple of deprecation warnings:

UserWarning: __floordiv__ is deprecated, and its behavior will
change in a future version of pytorch. It currently rounds toward 0
(like the 'trunc' function NOT 'floor'). This results in incorrect
rounding for negative values. To keep the current behavior, use
torch.div(a, b, rounding_mode='trunc')

Fix the problematic code accordingly, so that users won't see confusing warnings.

@sw005320 sw005320 added this to the v.202303 milestone Feb 19, 2023
When you do this:

    >>> speech2text = Speech2Text(...)

torch emits a couple of deprecation warnings:

    UserWarning: __floordiv__ is deprecated, and its behavior will change
    in a future version of pytorch. It currently rounds toward 0 (like the
    'trunc' function NOT 'floor'). This results in incorrect rounding for
    negative values. To keep the current behavior, use torch.div(a, b,
    rounding_mode='trunc')

Fix the issue as suggested by the error message.

Signed-off-by: Fujimoto Seiji <[email protected]>
@codecov
Copy link

codecov bot commented Feb 20, 2023

Codecov Report

Merging #4945 (919b3e5) into master (81a90d6) will decrease coverage by 2.12%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master    #4945      +/-   ##
==========================================
- Coverage   76.63%   74.52%   -2.12%     
==========================================
  Files         604      604              
  Lines       53934    53912      -22     
==========================================
- Hits        41334    40176    -1158     
- Misses      12600    13736    +1136     
Flag Coverage Δ
test_integration_espnet1 66.33% <40.00%> (-0.01%) ⬇️
test_integration_espnet2 47.43% <100.00%> (+<0.01%) ⬆️
test_python 64.20% <100.00%> (-2.35%) ⬇️
test_utils 23.08% <ø> (-0.27%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
espnet/nets/batch_beam_search.py 98.96% <100.00%> (+0.04%) ⬆️
espnet2/layers/stft.py 88.23% <100.00%> (+0.23%) ⬆️
espnet2/asr/state_spaces/attention.py 0.00% <0.00%> (-95.92%) ⬇️
espnet2/asr/state_spaces/ff.py 0.00% <0.00%> (-95.46%) ⬇️
espnet2/asr/frontend/whisper.py 18.46% <0.00%> (-73.85%) ⬇️
espnet2/asr/decoder/whisper_decoder.py 20.68% <0.00%> (-72.42%) ⬇️
espnet2/bin/whisper_export_vocabulary.py 20.45% <0.00%> (-70.46%) ⬇️
espnet2/enh/layers/beamformer_th.py 10.54% <0.00%> (-70.05%) ⬇️
espnet2/asr/decoder/s4_decoder.py 30.95% <0.00%> (-69.05%) ⬇️
espnet2/asr/encoder/whisper_encoder.py 16.47% <0.00%> (-65.89%) ⬇️
... and 23 more

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@sw005320 sw005320 merged commit 179d1f8 into espnet:master Feb 20, 2023
@sw005320
Copy link
Contributor

Thanks, @fujimotos!

@fujimotos fujimotos deleted the sf/floordiv branch February 21, 2023 00:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants