37 #include <hip/hip_fp16.h>
39 #include <half/half.hpp>
40 using halfhpp = half_float::half;
41 typedef halfhpp Rpp16f;
50 #include <x86intrin.h>
51 #include <smmintrin.h>
52 #include <immintrin.h>
57 #define RPP_MIN_8U ( 0 )
59 #define RPP_MAX_8U ( 255 )
61 #define RPPT_MAX_DIMS ( 5 )
63 #define RPPT_MAX_AUDIO_CHANNELS ( 16 )
65 #define CHECK_RETURN_STATUS(x) do { \
68 fprintf(stderr, "Runtime error: %s returned %d at %s:%d", #x, retval, __FILE__, __LINE__); \
74 #include <hip/hip_runtime.h>
75 #define RPP_HOST_DEVICE __host__ __device__
77 #define RPP_HOST_DEVICE
80 const float ONE_OVER_6 = 1.0f / 6;
81 const float ONE_OVER_3 = 1.0f / 3;
82 const float ONE_OVER_255 = 1.0f / 255;
83 const uint MMS_MAX_SCRATCH_MEMORY = 115293120;
84 const uint SPECTROGRAM_MAX_SCRATCH_MEMORY = 372877312;
175 rppStatusSuccess = 0,
176 rppStatusBadParm = -1,
177 rppStatusUnknownError = -2,
178 rppStatusNotInitialized = -3,
179 rppStatusInvalidValue = -4,
180 rppStatusAllocFailed = -5,
181 rppStatusInternalError = -6,
182 rppStatusNotImplemented = -7,
183 rppStatusUnsupportedOp = -8,
191 RPP_SCALAR_OP_AND = 1,
196 RPP_SCALAR_OP_NOTEQUAL,
198 RPP_SCALAR_OP_LESSEQ,
199 RPP_SCALAR_OP_GREATER,
200 RPP_SCALAR_OP_GREATEREQ,
202 RPP_SCALAR_OP_SUBTRACT,
203 RPP_SCALAR_OP_MULTIPLY,
204 RPP_SCALAR_OP_DIVIDE,
205 RPP_SCALAR_OP_MODULUS,
304 RPPI_HORIZONTAL_AXIS,
386 unsigned int roiWidth;
387 unsigned int roiHeight;
449 NEAREST_NEIGHBOR = 0,
510 int roiWidth, roiHeight;
520 int roiWidth, roiHeight, roiDepth;
643 float boxMullerExtra;
678 switch(interpolationType)
680 case RpptInterpolationType::BICUBIC:
685 case RpptInterpolationType::LANCZOS:
687 if(in_size > out_size)
689 this->radius = 3.0f * scaleRatio;
690 this->scale = (1 / scaleRatio);
696 case RpptInterpolationType::GAUSSIAN:
698 if(in_size > out_size)
700 this->radius = scaleRatio;
701 this->scale = (1 / scaleRatio);
705 case RpptInterpolationType::TRIANGULAR:
707 if(in_size > out_size)
709 this->radius = scaleRatio;
710 this->scale = (1 / scaleRatio);
721 this->size = std::ceil(2 * this->radius);
739 Rpp32f locRaw = x * scale + center;
740 Rpp32s locFloor = std::floor(locRaw);
741 Rpp32f weight = locRaw - locFloor;
742 locFloor = std::max(std::min(locFloor, lookupSize - 2), 0);
743 Rpp32f current = lookup[locFloor];
744 Rpp32f next = lookup[locFloor + 1];
745 return current + weight * (next - current);
748 inline __m128 operator()(__m128 x)
750 __m128 pLocRaw = _mm_add_ps(_mm_mul_ps(x, pScale), pCenter);
751 __m128i pxLocFloor = _mm_cvttps_epi32(pLocRaw);
752 __m128 pLocFloor = _mm_cvtepi32_ps(pxLocFloor);
753 __m128 pWeight = _mm_sub_ps(pLocRaw, pLocFloor);
755 _mm_storeu_si128(
reinterpret_cast<__m128i*
>(idx), pxLocFloor);
756 __m128 pCurrent = _mm_setr_ps(lookup[idx[0]], lookup[idx[1]], lookup[idx[2]], lookup[idx[3]]);
757 __m128 pNext = _mm_setr_ps(lookup[idx[0] + 1], lookup[idx[1] + 1], lookup[idx[2] + 1], lookup[idx[3] + 1]);
758 return _mm_add_ps(pCurrent, _mm_mul_ps(pWeight, _mm_sub_ps(pNext, pCurrent)));
761 Rpp32f scale = 1, center = 1;
762 Rpp32s lobes = 0, coeffs = 0;
764 Rpp32f *lookupPinned =
nullptr;
765 std::vector<Rpp32f> lookup;
766 __m128 pCenter, pScale;
775 inline RPP_HOST_DEVICE
virtual Rpp32f hz_to_mel(
Rpp32f hz) = 0;
776 inline RPP_HOST_DEVICE
virtual Rpp32f mel_to_hz(
Rpp32f mel) = 0;
785 inline RPP_HOST_DEVICE
Rpp32f hz_to_mel(
Rpp32f hz) {
return 1127.0f * std::log(1.0f + (hz / 700.0f)); }
786 inline RPP_HOST_DEVICE
Rpp32f mel_to_hz(
Rpp32f mel) {
return 700.0f * (std::exp(mel / 1127.0f) - 1.0f); }
797 const Rpp32f fsp = 66.666667f;
798 const Rpp32f minLogHz = 1000.0;
799 const Rpp32f minLogMel = (minLogHz - freqLow) / fsp;
800 const Rpp32f stepLog = 0.068751777;
802 const Rpp32f invMinLogHz = 0.001f;
803 const Rpp32f invStepLog = 1.0f / stepLog;
804 const Rpp32f invFsp = 1.0f / fsp;
810 mel = minLogMel + std::log(hz * invMinLogHz) * invStepLog;
812 mel = (hz - freqLow) * invFsp;
820 if (mel >= minLogMel)
821 hz = minLogHz * std::exp(stepLog * (mel - minLogMel));
823 hz = freqLow + mel * fsp;
928 Rpp32f *scratchBufferHost;
1015 clmemSize maxSrcSize;
1016 clmemSize maxDstSize;
1018 clmemRpp32f floatArr[10];
1019 clmemRpp64f doubleArr[10];
1020 clmemRpp32u uintArr[10];
1021 clmemRpp32s intArr[10];
1022 clmemRpp8u ucharArr[10];
1023 clmemRpp8s charArr[10];
1024 cl_mem srcBatchIndex;
1025 cl_mem dstBatchIndex;
1039 #elif defined(HIP_COMPILE)
RppiPad
RPPI Image pad type enum.
Definition: rppdefs.h:326
RppiFormat
RPPI Image format type enum.
Definition: rppdefs.h:335
unsigned int Rpp32u
32 bit unsigned int
Definition: rppdefs.h:97
RppConvertBitDepthMode
RPP BitDepth Conversion type enum.
Definition: rppdefs.h:214
int Rpp32s
32 bit signed int
Definition: rppdefs.h:99
signed char Rpp8s
8 bit signed char
Definition: rppdefs.h:91
RppiChnFormat
RPPI Image channel format type enum.
Definition: rppdefs.h:294
RpptMelScaleFormula
RPPT Mel Scale Formula.
Definition: rppdefs.h:471
unsigned short Rpp16u
16 bit unsigned short
Definition: rppdefs.h:93
unsigned char Rpp8u
8 bit unsigned char
Definition: rppdefs.h:89
void * RppPtr_t
void pointer
Definition: rppdefs.h:109
RpptLayout
RPPT Tensor layout type enum.
Definition: rppdefs.h:407
RppiBlur
RPPI Image blur type enum.
Definition: rppdefs.h:313
RppiAxis
RPP Image axis type enum.
Definition: rppdefs.h:303
RpptRoiType
RPPT Tensor 2D ROI type enum.
Definition: rppdefs.h:421
RpptDataType
RPPT Tensor datatype enum.
Definition: rppdefs.h:396
struct RpptResamplingWindow RpptResamplingWindow
RPPT Tensor RpptResamplingWindow type struct.
double Rpp64f
64 bit double
Definition: rppdefs.h:107
RpptAudioBorderType
RPPT Audio Border Type.
Definition: rppdefs.h:461
size_t RppSize_t
size_t
Definition: rppdefs.h:111
struct GenericFilter GenericFilter
RPPT Tensor GenericFilter type struct.
RppStatus
RPP RppStatus type enums.
Definition: rppdefs.h:117
RpptRoi3DType
RPPT Tensor 3D ROI type enum.
Definition: rppdefs.h:430
RppOp
RPP Operations type enum.
Definition: rppdefs.h:190
unsigned long long Rpp64u
64 bit unsigned long long
Definition: rppdefs.h:101
#define RPPT_MAX_DIMS
RPP maximum dimensions in tensor .
Definition: rppdefs.h:61
RpptInterpolationType
RPPT Tensor interpolation type enum.
Definition: rppdefs.h:448
RpptSubpixelLayout
RPPT Tensor subpixel layout type enum.
Definition: rppdefs.h:439
short Rpp16s
16 bit signed short
Definition: rppdefs.h:95
RppiColorConvertMode
RPPI Image color convert mode type enum.
Definition: rppdefs.h:275
float Rpp32f
32 bit float
Definition: rppdefs.h:105
RppiFuzzyLevel
RPPI Image fuzzy level type enum.
Definition: rppdefs.h:284
long long Rpp64s
64 bit long long
Definition: rppdefs.h:103
rppStatus_t
RPP rppStatus_t type enums.
Definition: rppdefs.h:174
@ RPP_ERROR_NOT_IMPLEMENTED
Function variant requested is not implemented / unsupported.
Definition: rppdefs.h:131
@ RPP_ERROR_INVALID_DST_DATATYPE
Invalid dst tensor datatype. (Needs to adhere to function specification.)
Definition: rppdefs.h:143
@ RPP_ERROR_INVALID_OUTPUT_TILE_LENGTH
Invalid output tile length (Needs to adhere to function specification.)
Definition: rppdefs.h:159
@ RPP_ERROR_OUT_OF_BOUND_SRC_ROI
Out of bound source ROI.
Definition: rppdefs.h:153
@ RPP_ERROR_OUT_OF_BOUND_SHARED_MEMORY_SIZE
Shared memory size needed is beyond the bounds (Needs to adhere to function specification....
Definition: rppdefs.h:161
@ RPP_ERROR_ZERO_DIVISION
Arguments provided will result in zero division error.
Definition: rppdefs.h:127
@ RPP_ERROR_INVALID_ARGUMENTS
One or more arguments invalid. (Needs to adhere to function specification.)
Definition: rppdefs.h:123
@ RPP_ERROR_LAYOUT_MISMATCH
src and dst layout mismatch
Definition: rppdefs.h:155
@ RPP_ERROR_INVALID_CHANNELS
Number of channels is invalid. (Needs to adhere to function specification.)
Definition: rppdefs.h:157
@ RPP_ERROR_INVALID_SRC_CHANNELS
Invalid src tensor number of channels. (Needs to adhere to function specification....
Definition: rppdefs.h:133
@ RPP_ERROR_INVALID_SRC_OR_DST_DATATYPE
Invalid src/dst tensor datatype. (Needs to adhere to function specification.)
Definition: rppdefs.h:145
@ RPP_ERROR_INVALID_PARAMETER_DATATYPE
Invalid datatype.
Definition: rppdefs.h:149
@ RPP_ERROR_NOT_ENOUGH_MEMORY
Not enough memory to write outputs, as per dim-lengths and strides set in descriptor.
Definition: rppdefs.h:151
@ RPP_ERROR
Unspecified error.
Definition: rppdefs.h:121
@ RPP_ERROR_INVALID_SRC_DIMS
Number of src dims is invalid. (Needs to adhere to function specification.)
Definition: rppdefs.h:165
@ RPP_ERROR_OUT_OF_BOUND_SCRATCH_MEMORY_SIZE
Scratch memory size needed is beyond the bounds (Needs to adhere to function specification....
Definition: rppdefs.h:163
@ RPP_ERROR_INVALID_DST_LAYOUT
Invalid dst tensor layout. (Needs to adhere to function specification.)
Definition: rppdefs.h:139
@ RPP_ERROR_INVALID_DST_CHANNELS
Invalid dst tensor number of channels. (Needs to adhere to function specification....
Definition: rppdefs.h:135
@ RPP_ERROR_INVALID_SRC_DATATYPE
Invalid src tensor datatype. (Needs to adhere to function specification.)
Definition: rppdefs.h:141
@ RPP_ERROR_INVALID_SRC_LAYOUT
Invalid src tensor layout. (Needs to adhere to function specification.)
Definition: rppdefs.h:137
@ RPP_ERROR_HIGH_SRC_DIMENSION
Src tensor / src ROI dimension too high. (Needs to adhere to function specification....
Definition: rppdefs.h:129
@ RPP_SUCCESS
No error.
Definition: rppdefs.h:119
@ RPP_ERROR_INSUFFICIENT_DST_BUFFER_LENGTH
Insufficient dst buffer length provided. (Needs to adhere to function specification....
Definition: rppdefs.h:147
@ RPP_ERROR_INVALID_DST_DIMS
Number of dst dims is invalid. (Needs to adhere to function specification.)
Definition: rppdefs.h:167
@ RPP_ERROR_LOW_OFFSET
Low tensor offsetInBytes provided for src/dst tensor.
Definition: rppdefs.h:125
Base class for Mel scale conversions.
Definition: rppdefs.h:773
RPPT Tensor GenericFilter type struct.
Definition: rppdefs.h:672
Derived class for HTK Mel scale conversions.
Definition: rppdefs.h:784
RPP initialize handle.
Definition: rppdefs.h:1175
RPP 24 float vector.
Definition: rppdefs.h:265
RPP 6 float vector.
Definition: rppdefs.h:241
RPP 9 float vector.
Definition: rppdefs.h:249
RPP 24 signed int vector.
Definition: rppdefs.h:257
RPP layout params.
Definition: rppdefs.h:232
RPP polar point.
Definition: rppdefs.h:223
RPPI Image 3D point type struct.
Definition: rppdefs.h:362
RPPI Image 2D cartesian point type struct.
Definition: rppdefs.h:353
RPPI Image 2D ROI (XYWH format) type struct.
Definition: rppdefs.h:383
RPPI Image 2D Rectangle (XYWH format) type struct.
Definition: rppdefs.h:372
RPPI Image size(Width/Height dimensions) type struct.
Definition: rppdefs.h:344
RPPT Tensor 2D bilinear neighborhood 32-bit signed int 8-length-vectors type struct.
Definition: rppdefs.h:650
RPPT Tensor 2D bilinear neighborhood 32-bit float 8-length-vectors type struct.
Definition: rppdefs.h:661
RPPT Tensor Channel Offsets struct.
Definition: rppdefs.h:489
RPPT Tensor descriptor type struct.
Definition: rppdefs.h:559
RPPT Tensor 32-bit float RGB type struct.
Definition: rppdefs.h:595
RPPT Tensor 2D 32-bit float vector type struct.
Definition: rppdefs.h:614
RPPT Tensor Generic descriptor type struct.
Definition: rppdefs.h:572
RPPT Tensor 2D image patch dimensions type struct.
Definition: rppdefs.h:623
RPPT Tensor 8-bit uchar RGB type struct.
Definition: rppdefs.h:585
RPPT Tensor RpptResamplingWindow type struct.
Definition: rppdefs.h:729
RPPT Tensor 3D ROI LTFRBB struct.
Definition: rppdefs.h:499
RPPT Tensor 2D ROI LTRB struct.
Definition: rppdefs.h:480
RPPT Tensor 2D ROI XYWH struct.
Definition: rppdefs.h:508
RPPT Tensor 3D ROI XYZWHD struct.
Definition: rppdefs.h:518
RPPT Tensor strides type struct.
Definition: rppdefs.h:548
RPPT Tensor 2D 32-bit uint vector type struct.
Definition: rppdefs.h:605
RPPT Tensor random number generator state (xorwow box muller state) type struct.
Definition: rppdefs.h:640
RPPT Tensor random number generator state (xorwow state) type struct.
Definition: rppdefs.h:632
Derived class for Slaney Mel scale conversions.
Definition: rppdefs.h:795
RPP HIP 2D ROI memory.
Definition: rppdefs.h:1112
RPP HIP 32-bit float memory.
Definition: rppdefs.h:1047
RPP HIP 32-bit signed int memory.
Definition: rppdefs.h:1071
RPP HIP 32-bit unsigned int memory.
Definition: rppdefs.h:1063
RPP HIP 64-bit double memory.
Definition: rppdefs.h:1055
RPP HIP 8-bit signed char memory.
Definition: rppdefs.h:1087
RPP HIP 8-bit unsigned char memory.
Definition: rppdefs.h:1079
RPP HIP RGB memory.
Definition: rppdefs.h:1095
RPP HIP 2D dimensions memory.
Definition: rppdefs.h:1103
RPP HOST memory type struct.
Definition: rppdefs.h:911
RPP OCL memory management type struct.
Definition: rppdefs.h:1123
RPP HIP-HOST memory management.
Definition: rppdefs.h:1154
RPP HOST 2D ROI memory.
Definition: rppdefs.h:901
RPP HOST 32-bit float memory.
Definition: rppdefs.h:836
RPP HOST 32-bit signed int memory.
Definition: rppdefs.h:860
RPP HOST 32-bit unsigned int memory.
Definition: rppdefs.h:852
RPP HOST 64-bit double memory.
Definition: rppdefs.h:844
RPP HOST 8-bit signed char memory.
Definition: rppdefs.h:876
RPP HOST 8-bit unsigned char memory.
Definition: rppdefs.h:868
RPP HOST RGB memory.
Definition: rppdefs.h:884
RPP HOST 2D dimensions memory.
Definition: rppdefs.h:892
RPPT Tensor 3D ROI union.
Definition: rppdefs.h:538
RPPT Tensor 2D ROI union.
Definition: rppdefs.h:528