Skip to content

Commit

Permalink
RPP Tensor Audio Support - Pre Emphasis Filter (#259)
Browse files Browse the repository at this point in the history
* Initial commit - Non slient region detection

Includes unittest setup

* Initial commit - To Decibels

Includes unittest setup

* Intial commit - pre_emphasis_filter

* Replace vectors with arrays

* Cleanup

* Minor cleanup

* Replace Rpp64s with Rpp32s

* Optimize and precompute cutOff

* Fix buffer used

* Fix buffer used

* Additional Cleanup

* Optimize post increment operation

* Update testsuite for Audio

* code cleanup

* Add Readme file for Audio test suite

* changes based on review comments

* minor change

* Remove unittest folders and updated README.md

* Remove unit tests

* minor change

* code cleanup

* added common header file for audio helper functions

* removed unncessary audio wav files

fixed bug in ROI updation for audio test suite

resolved issue in summary generation for performance tests in python

* removed log file

* added doxygen support for audio

* added doxygen changes for to_decibels

* updated test suite support for to_decibels

* minor change

* added doxygen changes for preemphasis filter

* updated changes for preemphasis filter in test suite

* removed the usage of getMax function and used std::max_element

* modularized code in test suite

* merge with latest changes

* minor change

* minor change

* minor change

* resolved codacy warnings

* Codacy fix - Remove unused cpuTime

* CMakeLists - Version Update

1.5.0 - TOT Version

* CHANGELOG Updates

Version 1.5.0 placeholder

* resolved issue with file_system dependency in test suite

* Doxygen changes

changed malloc to new in NSR kernel

* RPP RICAP Tensor for HOST and HIP (#213)

* Initial commit - Ricap HOST Tensor

Includes testsuite changes

* Add QA tests for RICAP

Used three_images_224x224_src1 folder to create golden outputs

* Add three_images_224x224_src1 into TEST_IMAGES

* Support HIP Backend for RICAP

* Fix HIP pkd3->pkd3 variant

* regenerated golden outputs for RICAP

minor changes in HOST shell script for handling RICAP in QA mode

* minor bug fix in RICAP HIP kernels

* Improve readability and Cleanup

* Additional cleanup

* Cleanup testsuite

Includes new golden outputs

* Additional testuite fixes

* Minor cleanup

* Fix codacy warnings

* Address other codacy warnings

* Update ricap.hpp with reference paper

* Add RICAP dataset path in readme

* Make changes to error codes returned

* Modify roi crop region for unit and perf tests

* RPP Tensor Water Augmentation on HOST and HIP (#181)

* added water HOST and HIP codes

* added water case in test suite

* added golden outputs for water

* added omp thread changes for water augmentation

* experimental changes

* fixed output issue with AVX2 instructions

* added AVX2 support for PKD3 load function

minor changes in PLN variant load functions

* nwc commit - added avx2 changes for u8 layout toggle variants but need to add store functions for completion

* Add Avx2 implementation for F32 and U8 toggle variants

* Add AVX2 support for u8 pkd3-pln3 and i8 pkd3-pln3 for water augmentation

* change F32 load and store logic

* optimized the store function for F32 PLN3-PKD3

* reverted back irrelevant changes

* minor change

* optimized load and store functions for water U8 and F32 variants in host

removed commented code

* removed golden outputs for water

* minor changes

* renamed few functions and removed unused functions

updated i8 pln1 load as per the optimized u8 pln1 load

* fixed bug in i8 load function

* changed cast to c++ style

resolved spacing issues and added comments for AVX codes for better understanding

made changes to handle cases where QA Tests are not supported

* added golden outputs for water

* updated golden outputs with latest changes

* modified the u8, i8 pkd3-pln3 function and added comments for the vectorized code

* fixed minor bug in I8 variants

* made to changes to resolve codacy warnings

* changed cast to c++ style in hip kernel

* changed generic nn F32 loads using gather and setr instructions

* added comments for latest changes

* minor change

* added definition for storing 32 and 64 bits from a 128bit register

---------

Co-authored-by: sampath1117 <sampath.rachumallu@multicorewareinc.com>
Co-authored-by: HazarathKumarM <hazarathkumar@multicorewareinc.com>

* Fix build error

* CMakeLists - Version Update

1.5.0 - TOT Version

* CHANGELOG Updates

Version 1.5.0 placeholder

* Boost deps fix for test suite

---------

Co-authored-by: Snehaa Giridharan <snehaa@multicorewareinc.com>
Co-authored-by: sampath1117 <sampath.rachumallu@multicorewareinc.com>
Co-authored-by: Snehaa-Giridharan <118163708+snehaa8@users.noreply.github.com>
Co-authored-by: HazarathKumarM <hazarathkumar@multicorewareinc.com>
Co-authored-by: Kiriti Gowda <kiritigowda@gmail.com>

* Documentation - Readme & changelog updates (#251)

* readme and changelog updates for 6.0

* minor update

* added ctests for audio test suite for CI

made changes to add more clarity on the QA Tests results

* Cmake mods for ctest

* HOST-only build error bugfix

* added qa mode paramter to python audio script

added golden output map for QA testing of Non silent region detection

* minor change

* Documentation - Bump rocm-docs-core[api_reference] from 0.26.0 to 0.27.0 in /docs/sphinx (#253)

Bumps [rocm-docs-core[api_reference]](https://github.com/RadeonOpenCompute/rocm-docs-core) from 0.26.0 to 0.27.0.
- [Release notes](https://github.com/RadeonOpenCompute/rocm-docs-core/releases)
- [Changelog](https://github.com/RadeonOpenCompute/rocm-docs-core/blob/develop/CHANGELOG.md)
- [Commits](ROCm/rocm-docs-core@v0.26.0...v0.27.0)

---
updated-dependencies:
- dependency-name: rocm-docs-core[api_reference]
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* RPP Resize Mirror Normalize Bugfix (#252)

* added fix for hipMemset

* remove pixel check for U8-F32 and U8-F16 for HOST codes

---------

Co-authored-by: sampath1117 <sampath.rachumallu@multicorewareinc.com>

* added example for MMS calculation in comments for better understanding

* Sphinx - updates (#257)

* Sphinx - updates

* Doxygen - Updates

* Docs - Remove index.md

* updated info used to for running audio test suite

* removed bitdepth variable from audio test suite

* added more information on computing NSR outputs in the example added

* Fix doxygen for decibels

Also removes extra QA reference files

* Fix build errors and qa tests in Audio Test suite

* Fix build errors and qa tests in Audio Test suite

* Remove auto-merge repeated funcs

* Improve clarity of header docs

* Remove blank line

* Improve clarity on header docs

* modified the branch statements used in kernel with ternary operator

* made changes based on review comments

* stored golden outputs of to_decibels in binary file

removed golden output text files for non silent region

* removed unused parameter in verify_output function

* stored pre emphasis filter golden output to binary file

* updated list of cases supported in python script

* updated list of cases supported in python script

* added error handling for opening golden output file

* added error handling for opening golden output file

* Codacy fix and tests warning fix

* Codacy fix

* Codacy fix trial

* codacy fix for checking boundaries of fstream

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Snehaa Giridharan <snehaa@multicorewareinc.com>
Co-authored-by: HazarathKumarM <hazarathkumar@multicorewareinc.com>
Co-authored-by: sampath1117 <sampath.rachumallu@multicorewareinc.com>
Co-authored-by: Kiriti Gowda <kiritigowda@gmail.com>
Co-authored-by: Snehaa-Giridharan <118163708+snehaa8@users.noreply.github.com>
Co-authored-by: Lisa <lisajdelaney@gmail.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
  • Loading branch information
8 people committed Dec 22, 2023
1 parent 8999c22 commit b2f3d2a
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 2 deletions.
10 changes: 10 additions & 0 deletions include/rppdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,16 @@ typedef enum
TRIANGULAR
} RpptInterpolationType;

/*! \brief RPPT Audio Border Type
* \ingroup group_rppdefs
*/
typedef enum
{
ZERO = 0,
CLAMP,
REFLECT
} RpptAudioBorderType;

/*! \brief RPPT Tensor 2D ROI LTRB struct
* \ingroup group_rppdefs
*/
Expand Down
16 changes: 16 additions & 0 deletions include/rppt_tensor_audio_augmentations.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,22 @@ RppStatus rppt_non_silent_region_detection_host(RppPtr_t srcPtr, RpptDescPtr src
*/
RppStatus rppt_to_decibels_host(RppPtr_t srcPtr, RpptDescPtr srcDescPtr, RppPtr_t dstPtr, RpptDescPtr dstDescPtr, RpptImagePatchPtr srcDims, Rpp32f cutOffDB, Rpp32f multiplier, Rpp32f referenceMagnitude, rppHandle_t rppHandle);

/*! \brief Pre Emphasis Filter augmentation on HOST backend
* \details Pre Emphasis Filter augmentation for audio data
* \param[in] srcPtr source tensor in HOST memory
* \param[in] srcDescPtr source tensor descriptor (Restrictions - numDims = 3, offsetInBytes >= 0, dataType = F32)
* \param[out] dstPtr destination tensor in HOST memory
* \param[in] dstDescPtr destination tensor descriptor (Restrictions - numDims = 3, offsetInBytes >= 0, dataType = F32)
* \param[in] srcLengthTensor source audio buffer length (1D tensor in HOST memory, of size batchSize)
* \param[in] coeffTensor preemphasis coefficient (1D tensor in HOST memory, of size batchSize)
* \param[in] borderType border value policy
* \param[in] rppHandle RPP HOST handle created with <tt>\ref rppCreateWithBatchSize()</tt>
* \return A <tt> \ref RppStatus</tt> enumeration.
* \retval RPP_SUCCESS Successful completion.
* \retval RPP_ERROR* Unsuccessful completion.
*/
RppStatus rppt_pre_emphasis_filter_host(RppPtr_t srcPtr, RpptDescPtr srcDescPtr, RppPtr_t dstPtr, RpptDescPtr dstDescPtr, Rpp32s *srcLengthTensor, Rpp32f *coeffTensor, RpptAudioBorderType borderType, rppHandle_t rppHandle);

#ifdef __cplusplus
}
#endif
Expand Down
1 change: 1 addition & 0 deletions src/modules/cpu/host_tensor_audio_augmentations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ THE SOFTWARE.

#include "kernel/non_silent_region_detection.hpp"
#include "kernel/to_decibels.hpp"
#include "kernel/pre_emphasis_filter.hpp"

#endif // HOST_TENSOR_AUDIO_AUGMENTATIONS_HPP
75 changes: 75 additions & 0 deletions src/modules/cpu/kernel/pre_emphasis_filter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
Copyright (c) 2019 - 2023 Advanced Micro Devices, Inc. All rights reserved.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#include "rppdefs.h"
#include "rpp_cpu_simd.hpp"
#include "rpp_cpu_common.hpp"

RppStatus pre_emphasis_filter_host_tensor(Rpp32f *srcPtr,
RpptDescPtr srcDescPtr,
Rpp32f *dstPtr,
RpptDescPtr dstDescPtr,
Rpp32s *srcLengthTensor,
Rpp32f *coeffTensor,
Rpp32u borderType,
rpp::Handle& handle)
{
Rpp32u numThreads = handle.GetNumThreads();

omp_set_dynamic(0);
#pragma omp parallel for num_threads(numThreads)
for(int batchCount = 0; batchCount < srcDescPtr->n; batchCount++)
{
Rpp32f *srcPtrTemp = srcPtr + batchCount * srcDescPtr->strides.nStride;
Rpp32f *dstPtrTemp = dstPtr + batchCount * dstDescPtr->strides.nStride;
Rpp32s bufferLength = srcLengthTensor[batchCount];
Rpp32f coeff = coeffTensor[batchCount];
Rpp32f border = (borderType == RpptAudioBorderType::CLAMP) ? srcPtrTemp[0] :
(borderType == RpptAudioBorderType::REFLECT) ? srcPtrTemp[1] : 0;
dstPtrTemp[0] = srcPtrTemp[0] - coeff * border;

Rpp32s vectorIncrement = 8;
Rpp32s alignedLength = (bufferLength / 8) * 8;
__m256 pCoeff = _mm256_set1_ps(coeff);

Rpp32s vectorLoopCount = 1;
dstPtrTemp++;
srcPtrTemp++;
for(; vectorLoopCount < alignedLength; vectorLoopCount += vectorIncrement)
{
__m256 pSrc[2];
pSrc[0] = _mm256_loadu_ps(srcPtrTemp);
pSrc[1] = _mm256_loadu_ps(srcPtrTemp - 1);
pSrc[1] = _mm256_sub_ps(pSrc[0], _mm256_mul_ps(pSrc[1], pCoeff));
_mm256_storeu_ps(dstPtrTemp, pSrc[1]);
srcPtrTemp += vectorIncrement;
dstPtrTemp += vectorIncrement;
}
for(; vectorLoopCount < bufferLength; vectorLoopCount++)
{
*dstPtrTemp++ = *srcPtrTemp - coeff * (*(srcPtrTemp - 1));
srcPtrTemp++;
}
}

return RPP_SUCCESS;
}
30 changes: 30 additions & 0 deletions src/modules/rppt_tensor_audio_augmentations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,33 @@ RppStatus rppt_to_decibels_host(RppPtr_t srcPtr,
return RPP_ERROR_INVALID_SRC_OR_DST_DATATYPE;
}
}

/******************** pre_emphasis_filter ********************/

RppStatus rppt_pre_emphasis_filter_host(RppPtr_t srcPtr,
RpptDescPtr srcDescPtr,
RppPtr_t dstPtr,
RpptDescPtr dstDescPtr,
Rpp32s *srcLengthTensor,
Rpp32f *coeffTensor,
RpptAudioBorderType borderType,
rppHandle_t rppHandle)
{
if ((srcDescPtr->dataType == RpptDataType::F32) && (dstDescPtr->dataType == RpptDataType::F32))
{
pre_emphasis_filter_host_tensor(static_cast<Rpp32f*>(srcPtr),
srcDescPtr,
static_cast<Rpp32f*>(dstPtr),
dstDescPtr,
srcLengthTensor,
coeffTensor,
borderType,
rpp::deref(rppHandle));

return RPP_SUCCESS;
}
else
{
return RPP_ERROR_NOT_IMPLEMENTED;
}
}
17 changes: 17 additions & 0 deletions utilities/test_suite/HOST/Tensor_host_audio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,23 @@ int main(int argc, char **argv)

break;
}
case 2:
{
testCaseName = "pre_emphasis_filter";
Rpp32f coeff[batchSize];
for (int i = 0; i < batchSize; i++)
{
coeff[i] = 0.97;
dstDims[i].height = srcLengthTensor[i];
dstDims[i].width = 1;
}
RpptAudioBorderType borderType = RpptAudioBorderType::CLAMP;

startWallTime = omp_get_wtime();
rppt_pre_emphasis_filter_host(inputf32, srcDescPtr, outputf32, dstDescPtr, srcLengthTensor, coeff, borderType, handle);

break;
}
default:
{
missingFuncFlag = 1;
Expand Down
4 changes: 2 additions & 2 deletions utilities/test_suite/HOST/runAudioTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
scriptPath = os.path.dirname(os.path.realpath(__file__))
inFilePath = scriptPath + "/../TEST_AUDIO_FILES/three_samples_single_channel_src1"
caseMin = 0
caseMax = 1
caseMax = 2

# Checks if the folder path is empty, or is it a root folder, or if it exists, and remove its contents
def validate_and_remove_files(path):
Expand Down Expand Up @@ -234,7 +234,7 @@ def rpp_test_suite_parser_and_validator():
run_performance_test(loggingFolder, srcPath, case, numRuns, testType, batchSize, outFilePath)

# print the results of qa tests
supportedCaseList = ['0', '1']
supportedCaseList = ['0', '1', '2']
nonQACaseList = [] # Add cases present in supportedCaseList, but without QA support

if testType == 0:
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions utilities/test_suite/rpp_test_suite_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ std::map<int, string> audioAugmentationMap =
{
{0, "non_silent_region_detection"},
{1, "to_decibels"},
{2, "pre_emphasis_filter"},
};

// Golden outputs for Non Silent Region Detection
Expand Down

0 comments on commit b2f3d2a

Please sign in to comment.