Add interleavedToPlanar kernels, normalize kernels and utiliy funcs

Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
Micaela Verucchi
2022-01-27 10:47:13 +01:00
parent 04de9908a6
commit c2825cc570
6 changed files with 160 additions and 2 deletions
+18 -1
View File
@@ -1,4 +1,4 @@
#include "kernelsThrust.h"
#include "kernels.h"
__global__
void normalize_kernel(float *bgr, const int dim, const float *mean, const float *stddev){
@@ -9,8 +9,25 @@ void normalize_kernel(float *bgr, const int dim, const float *mean, const float
}
__global__
void normalize_kernel(float *bgr, const int dim, const float mean, const float stddev){
int i = blockDim.x*blockIdx.x + threadIdx.x;
int j = blockIdx.y;
bgr[j*(dim)+i] = bgr[j*(dim)+i] - mean;
bgr[j*(dim)+i] = bgr[j*(dim)+i] / stddev;
}
void normalize(float *bgr, const int ch, const int h, const int w, const float *mean, const float *stddev){
int num_thread = 256;
dim3 dimBlock(h*w/num_thread, ch);
normalize_kernel<<<dimBlock, num_thread, 0>>>(bgr, h*w, mean, stddev);
}
void normalize(float *bgr, const int ch, const int h, const int w, const float mean, const float stddev){
int num_thread = 256;
dim3 dimBlock(h*w/num_thread, ch);
normalize_kernel<<<dimBlock, num_thread, 0>>>(bgr, h*w, mean, stddev);
}