Skip to content
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

RPP Tensor Audio Support - Pre Emphasis Filter #259

Merged
Merged
Show file tree
Hide file tree
Changes from 92 commits
Commits
Show all changes
112 commits
Select commit Hold shift + click to select a range
6627464
Initial commit - Non slient region detection
snehaa8 Aug 3, 2023
dcd9833
Initial commit - To Decibels
snehaa8 Aug 3, 2023
eb9e6eb
Intial commit - pre_emphasis_filter
HazarathKumarM Aug 5, 2023
3720c8f
Replace vectors with arrays
snehaa8 Aug 17, 2023
ed1e425
Cleanup
snehaa8 Aug 17, 2023
055fd59
Minor cleanup
snehaa8 Aug 18, 2023
f7f51c8
Replace Rpp64s with Rpp32s
snehaa8 Aug 24, 2023
676de7c
Optimize and precompute cutOff
snehaa8 Aug 25, 2023
46b8fb5
Fix buffer used
snehaa8 Sep 4, 2023
11fb3ab
Fix buffer used
snehaa8 Sep 4, 2023
8e05043
Additional Cleanup
snehaa8 Sep 4, 2023
195ccfc
Optimize post increment operation
snehaa8 Sep 4, 2023
79d9e6f
Update testsuite for Audio
snehaa8 Sep 8, 2023
5719db9
code cleanup
HazarathKumarM Sep 12, 2023
4aad4d6
Add Readme file for Audio test suite
HazarathKumarM Sep 12, 2023
abf15d8
changes based on review comments
HazarathKumarM Sep 12, 2023
71ef2f5
minor change
HazarathKumarM Sep 12, 2023
adad92b
Remove unittest folders and updated README.md
HazarathKumarM Sep 14, 2023
8e01e0e
Remove unit tests
HazarathKumarM Sep 14, 2023
69fba3e
minor change
HazarathKumarM Sep 14, 2023
a7b1b22
code cleanup
sampath1117 Sep 20, 2023
441bfac
added common header file for audio helper functions
sampath1117 Sep 20, 2023
c8803c2
Merge remote-tracking branch 'abishek_rpp/master' into sn/nsr_host_te…
sampath1117 Sep 20, 2023
e7169fe
removed unncessary audio wav files
sampath1117 Sep 20, 2023
11b4709
removed log file
sampath1117 Sep 20, 2023
d64bc7b
added doxygen support for audio
sampath1117 Sep 21, 2023
23ba5a5
Merge branch 'sn/nsr_host_tensor' into sn/to_decibels
sampath1117 Sep 22, 2023
337ccc1
added doxygen changes for to_decibels
sampath1117 Sep 22, 2023
d1b5b41
updated test suite support for to_decibels
sampath1117 Sep 22, 2023
223de61
minor change
sampath1117 Sep 22, 2023
bf0a4e0
added doxygen changes for preemphasis filter
sampath1117 Sep 22, 2023
f7d7589
Merge branch 'sn/to_decibels' into sn/pre_emphasis_filter
sampath1117 Sep 25, 2023
3626fc0
updated changes for preemphasis filter in test suite
sampath1117 Sep 25, 2023
512a79f
removed the usage of getMax function and used std::max_element
sampath1117 Sep 27, 2023
6a18957
modularized code in test suite
sampath1117 Sep 27, 2023
c413836
merge with latest changes
sampath1117 Sep 27, 2023
9f6b6d4
minor change
sampath1117 Sep 27, 2023
2247696
minor change
sampath1117 Sep 27, 2023
1ba334f
Merge branch 'sn/to_decibels' into sn/pre_emphasis_filter
sampath1117 Sep 27, 2023
527ed18
minor change
sampath1117 Sep 27, 2023
87b0138
Merge pull request #149 from snehaa8/sn/nsr_host_tensor
r-abishek Sep 27, 2023
8e2975d
resolved codacy warnings
sampath1117 Sep 28, 2023
b9f8c12
Merge pull request #174 from snehaa8/sn/nsr_host_tensor
r-abishek Sep 28, 2023
b22bf93
Codacy fix - Remove unused cpuTime
r-abishek Sep 28, 2023
4a5c357
CMakeLists - Version Update
kiritigowda Oct 23, 2023
2c8a78b
CHANGELOG Updates
kiritigowda Oct 23, 2023
f07786a
merge with latest changes
sampath1117 Oct 24, 2023
54cfa29
resolved issue with file_system dependency in test suite
sampath1117 Oct 24, 2023
c8bd726
Doxygen changes
sampath1117 Oct 24, 2023
92f8ed7
Merge pull request #182 from sampath1117/sr/nsr_pr_changes
r-abishek Oct 25, 2023
c4d8f3d
Merge branch 'develop' into ar/audio_support_1_non_silent_region
r-abishek Nov 1, 2023
1db1425
RPP RICAP Tensor for HOST and HIP (#213)
r-abishek Nov 1, 2023
1d3e7ce
Documentation - Readme & changelog updates (#251)
LisaDelaney Nov 1, 2023
13995ad
Merge branch 'ar/audio_support_1_non_silent_region' into sn/nsr_host_…
sampath1117 Nov 2, 2023
e85f581
added ctests for audio test suite for CI
sampath1117 Nov 2, 2023
296ed72
Merge pull request #187 from snehaa8/sn/nsr_host_tensor
r-abishek Nov 2, 2023
0aec6e1
Cmake mods for ctest
r-abishek Nov 2, 2023
3140717
HOST-only build error bugfix
r-abishek Nov 2, 2023
fe4ef51
Merge branch 'ar/audio_support_1_non_silent_region' into sn/nsr_host_…
sampath1117 Nov 3, 2023
0713890
added qa mode paramter to python audio script
sampath1117 Nov 3, 2023
e98a4e8
minor change
sampath1117 Nov 3, 2023
a1f7366
Documentation - Bump rocm-docs-core[api_reference] from 0.26.0 to 0.2…
dependabot[bot] Nov 3, 2023
749a552
RPP Resize Mirror Normalize Bugfix (#252)
r-abishek Nov 3, 2023
3f5aec6
Merge pull request #189 from snehaa8/sn/nsr_host_tensor
r-abishek Nov 3, 2023
1b466bc
added example for MMS calculation in comments for better understanding
sampath1117 Nov 7, 2023
38119f3
Sphinx - updates (#257)
kiritigowda Nov 7, 2023
b98bb99
updated info used to for running audio test suite
sampath1117 Nov 8, 2023
3795f37
removed bitdepth variable from audio test suite
sampath1117 Nov 10, 2023
58e1ff5
added more information on computing NSR outputs in the example added
sampath1117 Nov 10, 2023
64c52cd
Merge pull request #191 from snehaa8/sn/nsr_host_tensor
r-abishek Nov 13, 2023
6b2add5
Merge branch 'ar/audio_support_1_non_silent_region' of https://github…
r-abishek Nov 14, 2023
7753fda
Merge branch 'ar/audio_support_2_to_decibels' into sn/to_decibels
r-abishek Nov 14, 2023
072cc1e
Merge pull request #150 from snehaa8/sn/to_decibels
r-abishek Nov 14, 2023
e04371d
Merge branch 'ar/audio_support_1_non_silent_region' of https://github…
r-abishek Nov 14, 2023
1f25169
Merge branch 'ar/audio_support_2_to_decibels' of https://github.com/r…
r-abishek Nov 14, 2023
8e16be8
Merge branch 'ar/audio_support_3_pre_emphasis_filter' into sn/pre_emp…
r-abishek Nov 14, 2023
e261ce3
Merge pull request #151 from snehaa8/sn/pre_emphasis_filter
r-abishek Nov 14, 2023
d205055
Fix doxygen for decibels
snehaa8 Nov 15, 2023
f9c66a6
Merge pull request #195 from snehaa8/sn/to_decibels
r-abishek Nov 15, 2023
da528d3
Fix build errors and qa tests in Audio Test suite
snehaa8 Nov 16, 2023
ce13b82
Fix build errors and qa tests in Audio Test suite
snehaa8 Nov 16, 2023
a90e280
Merge pull request #197 from snehaa8/sn/to_decibels
r-abishek Nov 16, 2023
5713d1d
Merge branch 'ar/audio_support_2_to_decibels' of https://github.com/r…
r-abishek Nov 16, 2023
8ae8673
Merge branch 'ar/audio_support_3_pre_emphasis_filter' into sn/pre_emp…
r-abishek Nov 16, 2023
9c8ac7f
Merge pull request #198 from snehaa8/sn/pre_emphasis_filter
r-abishek Nov 16, 2023
8227726
Merge branch 'master' of https://github.com/GPUOpen-ProfessionalCompu…
r-abishek Nov 22, 2023
783ee98
Remove auto-merge repeated funcs
r-abishek Nov 22, 2023
900672a
Merge branch 'ar/audio_support_2_to_decibels' of https://github.com/r…
r-abishek Nov 22, 2023
7e91a91
Improve clarity of header docs
r-abishek Nov 22, 2023
3b03aad
Remove blank line
r-abishek Nov 22, 2023
2be82b1
Improve clarity on header docs
r-abishek Nov 22, 2023
934276a
Merge branch 'ar/audio_support_2_to_decibels' of https://github.com/r…
r-abishek Nov 22, 2023
b8bcb04
modified the branch statements used in kernel with ternary operator
sampath1117 Nov 28, 2023
1875d85
made changes based on review comments
sampath1117 Nov 28, 2023
132eaa6
stored golden outputs of to_decibels in binary file
sampath1117 Nov 30, 2023
9322cd0
removed unused parameter in verify_output function
sampath1117 Nov 30, 2023
22a78f2
Merge branch 'sr/to_decibels_pr_changes' into sr/pre_emphasis_pr_changes
sampath1117 Nov 30, 2023
e5886e3
stored pre emphasis filter golden output to binary file
sampath1117 Nov 30, 2023
777a9f9
updated list of cases supported in python script
sampath1117 Nov 30, 2023
b650f02
updated list of cases supported in python script
sampath1117 Nov 30, 2023
f3d0a7d
added error handling for opening golden output file
sampath1117 Nov 30, 2023
7790cf6
added error handling for opening golden output file
sampath1117 Nov 30, 2023
1135cbc
Merge pull request #202 from sampath1117/sr/to_decibels_pr_changes
r-abishek Nov 30, 2023
40f2cc9
Codacy fix and tests warning fix
r-abishek Dec 5, 2023
3b6d418
Merge pull request #201 from sampath1117/sr/pre_emphasis_pr_changes
r-abishek Dec 5, 2023
5aa53cb
Codacy fix
r-abishek Dec 5, 2023
8dc04bb
Codacy fix trial
r-abishek Dec 5, 2023
331f160
merge with latest changes
sampath1117 Dec 7, 2023
4ec92c6
codacy fix for checking boundaries of fstream
sampath1117 Dec 7, 2023
b7cf24f
Merge pull request #205 from sampath1117/sr/to_decibels_pr_changes
r-abishek Dec 7, 2023
8e1b374
Merge branch 'ar/audio_support_2_to_decibels' of https://github.com/r…
r-abishek Dec 13, 2023
8f2775d
Merge branch 'develop' into ar/audio_support_3_pre_emphasis_filter
r-abishek Dec 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
33 changes: 33 additions & 0 deletions include/rppt_tensor_audio_augmentations.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,39 @@ extern "C" {
*/
RppStatus rppt_non_silent_region_detection_host(RppPtr_t srcPtr, RpptDescPtr srcDescPtr, Rpp32s *srcLengthTensor, Rpp32f *detectedIndexTensor, Rpp32f *detectionLengthTensor, Rpp32f cutOffDB, Rpp32s windowLength, Rpp32f referencePower, Rpp32s resetInterval, rppHandle_t rppHandle);

/*! \brief To Decibels augmentation on HOST backend
* \details To Decibels augmentation for 1D audio buffer converts magnitude values to decibel values
* \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] srcDims source tensor sizes for each element in batch (2D tensor in HOST memory, of size batchSize * 2)
* \param[in] cutOffDB minimum or cut-off ratio in dB
* \param[in] multiplier factor by which the logarithm is multiplied
* \param[in] referenceMagnitude Reference magnitude if not provided maximum value of input used as reference
* \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_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
2 changes: 2 additions & 0 deletions src/modules/cpu/host_tensor_audio_augmentations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ THE SOFTWARE.
#define HOST_TENSOR_AUDIO_AUGMENTATIONS_HPP

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

#endif // HOST_TENSOR_AUDIO_AUGMENTATIONS_HPP
87 changes: 87 additions & 0 deletions src/modules/cpu/kernel/pre_emphasis_filter.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
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];

if(borderType == RpptAudioBorderType::ZERO)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please all the if else conditions with better code
border = (borderType = RpptAudioBorderType::CLAMP) ? SrcptrTemp[0] : (borderType = RpptAudioBorderType::REFLECT) ? SrcptrTemp[1] : 0;
dstPtrTemp[0] = srcPtrTemp[0] - coeff * border;

dstPtrTemp[0] = srcPtrTemp[0];
else if(borderType == RpptAudioBorderType::CLAMP)
{
Rpp32f border = srcPtrTemp[0];
dstPtrTemp[0] = srcPtrTemp[0] - coeff * border;
}
else if(borderType == RpptAudioBorderType::REFLECT)
{
Rpp32f border = srcPtrTemp[1];
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;
}
106 changes: 106 additions & 0 deletions src/modules/cpu/kernel/to_decibels.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/*
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 <omp.h>

RppStatus to_decibels_host_tensor(Rpp32f *srcPtr,
RpptDescPtr srcDescPtr,
Rpp32f *dstPtr,
RpptDescPtr dstDescPtr,
RpptImagePatchPtr srcDims,
Rpp32f cutOffDB,
Rpp32f multiplier,
Rpp32f referenceMagnitude,
rpp::Handle& handle)
{
Rpp32u numThreads = handle.GetNumThreads();

// Calculate the intermediate values needed for DB conversion
Rpp32f minRatio = std::pow(10, cutOffDB / multiplier);
if(minRatio == 0.0f)
minRatio = std::nextafter(0.0f, 1.0f);

const Rpp32f log10Factor = 0.3010299956639812; //1 / std::log(10);
multiplier *= log10Factor;

omp_set_dynamic(0);
#pragma omp parallel for num_threads(numThreads)
for(int batchCount = 0; batchCount < srcDescPtr->n; batchCount++)
{
Rpp32f *srcPtrCurrent = srcPtr + batchCount * srcDescPtr->strides.nStride;
Rpp32f *dstPtrCurrent = dstPtr + batchCount * dstDescPtr->strides.nStride;

Rpp32u height = srcDims[batchCount].height;
Rpp32u width = srcDims[batchCount].width;
Rpp32f refMag = referenceMagnitude;

// Compute maximum value in the input buffer
if(!referenceMagnitude)
{
refMag = -std::numeric_limits<Rpp32f>::max();
Rpp32f *srcPtrTemp = srcPtrCurrent;
if(width == 1)
refMag = std::max(refMag, *(std::max_element(srcPtrTemp, srcPtrTemp + height)));
else
{
for(int i = 0; i < height; i++)
{
refMag = std::max(refMag, *(std::max_element(srcPtrTemp, srcPtrTemp + width)));
srcPtrTemp += srcDescPtr->strides.hStride;
}
}
}

// Avoid division by zero
if(!refMag)
refMag = 1.0f;

Rpp32f invReferenceMagnitude = 1.f / refMag;
// Interpret as 1D array
if(width == 1)
{
for(Rpp32s vectorLoopCount = 0; vectorLoopCount < height; vectorLoopCount++)
*dstPtrCurrent++ = multiplier * std::log2(std::max(minRatio, (*srcPtrCurrent++) * invReferenceMagnitude));
}
else
{
Rpp32f *srcPtrRow, *dstPtrRow;
srcPtrRow = srcPtrCurrent;
dstPtrRow = dstPtrCurrent;
for(int i = 0; i < height; i++)
{
Rpp32f *srcPtrTemp, *dstPtrTemp;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can get rid of Temp variables and directly use srcPtrRow and dstPtrRow. For stride increment on line 99 &100 just add (stride-w)

srcPtrTemp = srcPtrRow;
dstPtrTemp = dstPtrRow;
Rpp32s vectorLoopCount = 0;
for(; vectorLoopCount < width; vectorLoopCount++)
*dstPtrTemp++ = multiplier * std::log2(std::max(minRatio, (*srcPtrTemp++) * invReferenceMagnitude));

srcPtrRow += srcDescPtr->strides.hStride;
dstPtrRow += dstDescPtr->strides.hStride;
}
}
}

return RPP_SUCCESS;
}
64 changes: 64 additions & 0 deletions src/modules/rppt_tensor_audio_augmentations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,67 @@ RppStatus rppt_non_silent_region_detection_host(RppPtr_t srcPtr,

return RPP_SUCCESS;
}

/******************** to_decibels ********************/

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)
{
if (multiplier == 0)
return RPP_ERROR_ZERO_DIVISION;
if ((srcDescPtr->dataType == RpptDataType::F32) && (dstDescPtr->dataType == RpptDataType::F32))
{
to_decibels_host_tensor(static_cast<Rpp32f*>(srcPtr),
srcDescPtr,
static_cast<Rpp32f*>(dstPtr),
dstDescPtr,
srcDims,
cutOffDB,
multiplier,
referenceMagnitude,
rpp::deref(rppHandle));

return RPP_SUCCESS;
}
else
{
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;
}
}
2 changes: 1 addition & 1 deletion utilities/test_suite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,4 @@ if(Python3_FOUND)

else()
message("-- ${Yellow}Test Warning: Python3 must be installed to run RPP test_suite successfully!${ColourReset}")
endif(Python3_FOUND)
endif(Python3_FOUND)
12 changes: 12 additions & 0 deletions utilities/test_suite/HIP/Tensor_hip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,18 @@ int main(int argc, char **argv)
double wallTime;
string testCaseName;

if(testCase == 82 && imagesMixed)
{
std::cerr<<"\n RICAP only works with same dimension images";
exit(0);
}

if(testCase == 82 && batchSize < 2)
{
std::cerr<<"\n RICAP only works with BatchSize > 1";
exit(0);
}

// Initialize buffers for any reductionType functions
void *reductionFuncResultArr;
Rpp32u reductionFuncResultArrLength = srcDescPtr->n * 4;
Expand Down
12 changes: 12 additions & 0 deletions utilities/test_suite/HOST/Tensor_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,18 @@ int main(int argc, char **argv)
double cpuTime, wallTime;
string testCaseName;

if(testCase == 82 && imagesMixed)
{
std::cerr<<"\n RICAP only works with same dimension images";
exit(0);
}

if(testCase == 82 && batchSize < 2)
{
std::cerr<<"\n RICAP only works with BatchSize > 1";
exit(0);
}

// Initialize buffers for any reductionType functions
void *reductionFuncResultArr;
Rpp32u reductionFuncResultArrLength = srcDescPtr->n * 4;
Expand Down
Loading