Add interleavedToPlanar kernels, normalize kernels and utiliy funcs
Signed-off-by: Micaela Verucchi <micaelaverucchi@gmail.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user