In preparation for adding AVX2 code, a safe scheme to support
different SIMD optimizations is added.
Safety features:
- AVX2 kill switch to stop using it even if supported by the
architecture
- struct indicating the available CPU features propagated from
AGC2 to each component; in this way
- better control over the unit tests
- no need to propagate individual kill switches but just
set to false features that are turned off
Note that (i) this CL does not change the performance of the RNN VAD
and (ii) no AVX2 optimization is added yet.
Bug: webrtc:10480
Change-Id: I0e61f3311ecd140f38369cf68b6e5954f3dc1f5a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/193140
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32739}
This reverts commit 9da3e177fd.
Reason for revert: bug in ComputePitchPeriod48kHz()
Original change's description:
> RNN VAD: pitch search optimizations (part 1)
>
> TL;DR this CL improves efficiency and includes several code
> readability improvements mainly triggered by the comments to
> patch set #10.
>
> Highlights:
> - Split `FindBestPitchPeriods()` into 12 and 24 kHz versions
> to hard-code the input size and simplify the 24 kHz version
> - Loop in `ComputePitchPeriod48kHz()` (new name for
> `RefinePitchPeriod48kHz()`) removed since the lags for which
> we need to compute the auto correlation are a few
> - `ComputePitchGainThreshold()` was only used in unit tests; it's been
> moved into the anon ns and the test removed
>
> This CL makes `ComputePitchPeriod48kHz()` is about 10% faster (measured
> with https://webrtc-review.googlesource.com/c/src/+/191320/4/modules/audio_processing/agc2/rnn_vad/pitch_search_internal_unittest.cc).
> The realtime factor has improved by about +14%.
>
> Benchmarked as follows:
> ```
> out/release/modules_unittests \
> --gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \
> --gtest_also_run_disabled_tests --logs
> ```
>
> Results:
>
> | baseline | this CL
> ------+----------------------+------------------------
> run 1 | 24.0231 +/- 0.591016 | 23.568 +/- 0.990788
> | 370.06x | 377.207x
> ------+----------------------+------------------------
> run 2 | 24.0485 +/- 0.957498 | 23.3714 +/- 0.857523
> | 369.67x | 380.379x
> ------+----------------------+------------------------
> run 2 | 25.4091 +/- 2.6123 | 23.709 +/- 1.04477
> | 349.875x | 374.963x
>
> Bug: webrtc:10480
> Change-Id: I9a3e9164b2442114b928de506c92a547c273882f
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191320
> Reviewed-by: Per Åhgren <peah@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#32568}
TBR=alessiob@webrtc.org,peah@webrtc.org
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10480
Change-Id: I2a91f4f29566f872a7dfa220b31c6c625ed075db
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/192660
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32581}
TL;DR this CL improves efficiency and includes several code
readability improvements mainly triggered by the comments to
patch set #10.
Highlights:
- Split `FindBestPitchPeriods()` into 12 and 24 kHz versions
to hard-code the input size and simplify the 24 kHz version
- Loop in `ComputePitchPeriod48kHz()` (new name for
`RefinePitchPeriod48kHz()`) removed since the lags for which
we need to compute the auto correlation are a few
- `ComputePitchGainThreshold()` was only used in unit tests; it's been
moved into the anon ns and the test removed
This CL makes `ComputePitchPeriod48kHz()` is about 10% faster (measured
with https://webrtc-review.googlesource.com/c/src/+/191320/4/modules/audio_processing/agc2/rnn_vad/pitch_search_internal_unittest.cc).
The realtime factor has improved by about +14%.
Benchmarked as follows:
```
out/release/modules_unittests \
--gtest_filter=*RnnVadTest.DISABLED_RnnVadPerformance* \
--gtest_also_run_disabled_tests --logs
```
Results:
| baseline | this CL
------+----------------------+------------------------
run 1 | 24.0231 +/- 0.591016 | 23.568 +/- 0.990788
| 370.06x | 377.207x
------+----------------------+------------------------
run 2 | 24.0485 +/- 0.957498 | 23.3714 +/- 0.857523
| 369.67x | 380.379x
------+----------------------+------------------------
run 2 | 25.4091 +/- 2.6123 | 23.709 +/- 1.04477
| 349.875x | 374.963x
Bug: webrtc:10480
Change-Id: I9a3e9164b2442114b928de506c92a547c273882f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/191320
Reviewed-by: Per Åhgren <peah@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#32568}
This reverts commit 7350a90237.
Reason for revert: possibly breaking downstream projects
Original change's description:
> RNN VAD: prepare for SIMD optimization
>
> This CL adds the boilerplate for SIMD optimization of FC and GRU layers
> in rnn.cc. The same scheme of AEC3 has been used. Unit tests for the
> optimized architectures have been added (the same unoptimized
> implementation will run).
>
> Minor changes:
> - unnecessary const removed in rnn.h
> - FC and GRU test data in the anon namespace as constexpr
>
> Bug: webrtc:10480
> Change-Id: Ifae4e970326e7e7c603d49aeaf61194b5efdabd3
> Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/141419
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#29696}
TBR=gustaf@webrtc.org,alessiob@webrtc.org,fhernqvist@webrtc.org
Change-Id: I9ae82f4bd2d30797646fabfb5ad16bea378208b8
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:10480
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/158893
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29699}
This CL adds the boilerplate for SIMD optimization of FC and GRU layers
in rnn.cc. The same scheme of AEC3 has been used. Unit tests for the
optimized architectures have been added (the same unoptimized
implementation will run).
Minor changes:
- unnecessary const removed in rnn.h
- FC and GRU test data in the anon namespace as constexpr
Bug: webrtc:10480
Change-Id: Ifae4e970326e7e7c603d49aeaf61194b5efdabd3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/141419
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Gustaf Ullberg <gustaf@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#29696}
This CL replaces KissFFT with PFFFT for the spectral features
computation.
Remarks:
- Extra FFT output vector copy eliminated
- Scaling and windowing merged into a single vector for efficiency
- Nyquist frequency hack to keep the iteration in
BandFeaturesExtractor::ComputeSpectralCrossCorrelation simple
Bug: webrtc:9577, webrtc:10480
Change-Id: I436563bd257f66a243f5402be270ffcf859bd184
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/130221
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27536}
This CL refactors the computation of band energy and spectral
cross-correlation coefficients by moving and optimizing
the code from ComputeBandCoefficients, ComputeBandEnergies and
ComputeSpectralCrossCorrelation into a single class (named
BandFeaturesExtractor).
This change will also help replacing FFT library in the RNN VAD.
Bug: webrtc:10480
Change-Id: I6cefa23e8f3bc8de6eb09d3ea434699d5e19124e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/129726
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27535}
This CL defines SpectralFeaturesExtractor which is responsible for
computing the spectral features used as input for the RNN.
Bug: webrtc:9076
Change-Id: I5e1396b89eca9c13bb268e8419a16436a9c3450f
Reviewed-on: https://webrtc-review.googlesource.com/73760
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23206}
This CL adds helper functions to be used for the spectral features
computation. Namely, it includes the following:
- band boundaries (frequency to FFT coeffcient index)
- band energy coefficients
- log band energy coefficients
- fixed size DCT table and computation
Bug: webrtc:9076
Change-Id: I03a8799b226d986bc1e37cefd0c3039f94b5592a
Reviewed-on: https://webrtc-review.googlesource.com/73687
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Minyue Li <minyue@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23170}
BandAnalysisFft class that wraps the FFT library, makes it easy to change
FFT library, applies windowing function and owns the FFT input buffer.
Bug: webrtc:9076
Change-Id: I9e7ed587ae263b906e04a66bf8c06eaae64daf19
Reviewed-on: https://webrtc-review.googlesource.com/72900
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23150}
RNN implementation for the AGC2 VAD that includes a fully connected
layer and a gated recurrent unit layer.
Bug: webrtc:9076
Change-Id: Ibb8b0b4e9213f09eb9dbe118bbdc94d7e8e4f91b
Reviewed-on: https://webrtc-review.googlesource.com/72060
Reviewed-by: Patrik Höglund <phoglund@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Ivo Creusen <ivoc@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23101}
Functions to estimate pitch period and gain.
Bug: webrtc:9076
Change-Id: Icfe9430dcae11bdb96165c5bfe6e2b1d3bf848ab
Reviewed-on: https://webrtc-review.googlesource.com/70382
Commit-Queue: Alex Loiko <aleloi@webrtc.org>
Reviewed-by: Per Åhgren <peah@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23066}
Functions to estimate the inverse filter via LPC and compute the LP
residual applying the inverse filter.
This CL also includes test utilities, in particular BinaryFileReader,
used to read chunks of data and optionally cast them on the fly, and
Create*Reader() functions to read resource files available at test
time.
Bug: webrtc:9076
Change-Id: Ia4793b8ad6a63cb3089ed11ddad89d1aa0b840f6
Reviewed-on: https://webrtc-review.googlesource.com/70244
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Reviewed-by: Jesus de Vicente Pena <devicentepena@webrtc.org>
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22946}
This reverts commit 8628f5bb7c.
Reason for revert: iOS buildbot failing
Original change's description:
> AGC2 RNN VAD: initial build targets
>
> rnn_vad_tool is an executable that reads a wav file of any sample rate
> compatible with 10 ms frames that are resampled and, when the VAD is
> fully landed, will process the resampled frames to compute the VAD
> probability.
>
> To avoid mac, win and ios trybot failures, to_be_removed.h/.cc have
> been added and will be removed as soon as the :lib target includes
> code that leads to a non-empty static lib file on those platforms.
>
> Bug: webrtc:9076
> Change-Id: I810c08acfa1adf2029e3baac2adda3045ae5214a
> Reviewed-on: https://webrtc-review.googlesource.com/70202
> Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22898}
TBR=alessiob@webrtc.org,aleloi@webrtc.org
Change-Id: Ic6014dde78b0ef371804c52608145ba8acdd9c97
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:9076
Reviewed-on: https://webrtc-review.googlesource.com/70144
Reviewed-by: Alessio Bazzica <alessiob@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22899}
rnn_vad_tool is an executable that reads a wav file of any sample rate
compatible with 10 ms frames that are resampled and, when the VAD is
fully landed, will process the resampled frames to compute the VAD
probability.
To avoid mac, win and ios trybot failures, to_be_removed.h/.cc have
been added and will be removed as soon as the :lib target includes
code that leads to a non-empty static lib file on those platforms.
Bug: webrtc:9076
Change-Id: I810c08acfa1adf2029e3baac2adda3045ae5214a
Reviewed-on: https://webrtc-review.googlesource.com/70202
Reviewed-by: Alex Loiko <aleloi@webrtc.org>
Commit-Queue: Alessio Bazzica <alessiob@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22898}