cuda: floor -> floorf, ceil -> ceilf

This commit is contained in:
hainq 2021-03-19 12:13:26 +07:00
parent b8c9c9d457
commit 0bd7e6713d
3 changed files with 25 additions and 25 deletions

View File

@ -85,7 +85,7 @@ __device__ float gelu_gradient_kernel(float x) {
__device__ float plse_gradient_kernel(float x){return (x < 0 || x > 1) ? .01f : .125f;}
__device__ float stair_gradient_kernel(float x)
{
if (floor(x) == x) return 0;
if (floorf(x) == x) return 0;
return 1;
}

View File

@ -1758,11 +1758,11 @@ __global__ void smooth_rotate_weights_kernel(const float *src_weight_gpu, float
float x_s = x_c + (x - x_c)*cos_a + (y - y_c)*sin_a;
float y_s = y_c - (x - x_c)*sin_a + (y - y_c)*cos_a;
int x_0 = floor(x_s); // round down
int x_1 = ceil(x_s); // round up
int x_0 = floorf(x_s); // round down
int x_1 = ceilf(x_s); // round up
if (x_0 == x_1) x_1 = x_0 + 1;
int y_0 = floor(y_s);
int y_1 = ceil(y_s);
int y_0 = floorf(y_s);
int y_1 = ceilf(y_s);
if (y_0 == y_1) y_1 = y_0 + 1;
float c_x_0 = x_1 - x_s;
@ -1855,11 +1855,11 @@ __global__ void stretch_weights_kernel(const float *src_weight_gpu, float *weig
float x_s = x_c + (x - x_c) / scale;
float y_s = y_c + (y - y_c) / scale;
int x_0 = floor(x_s); // round down
int x_1 = ceil(x_s); // round up
int x_0 = floorf(x_s); // round down
int x_1 = ceilf(x_s); // round up
if (x_0 == x_1) x_1 = x_0 + 1;
int y_0 = floor(y_s);
int y_1 = ceil(y_s);
int y_0 = floorf(y_s);
int y_1 = ceilf(y_s);
if (y_0 == y_1) y_1 = y_0 + 1;
float c_x_0 = x_1 - x_s;
@ -1953,11 +1953,11 @@ __global__ void sway_and_flip_weights_kernel(const float *src_weight_gpu, float
float x_s = x_c + (x - x_c)*cos_a + (y - y_c)*sin_a;
float y_s = y_c - (x - x_c)*sin_a + (y - y_c)*cos_a;
int x_0 = floor(x_s); // round down
int x_1 = ceil(x_s); // round up
int x_0 = floorf(x_s); // round down
int x_1 = ceilf(x_s); // round up
if (x_0 == x_1) x_1 = x_0 + 1;
int y_0 = floor(y_s);
int y_1 = ceil(y_s);
int y_0 = floorf(y_s);
int y_1 = ceilf(y_s);
if (y_0 == y_1) y_1 = y_0 + 1;
float c_x_0 = x_1 - x_s;
@ -2144,11 +2144,11 @@ __global__ void stretch_sway_flip_weights_kernel(const float *src_weight_gpu, f
float x_s = x_c + (x - x_c) / scale;
float y_s = y_c + (y - y_c) / scale;
int x_0 = floor(x_s); // round down
int x_1 = ceil(x_s); // round up
int x_0 = floorf(x_s); // round down
int x_1 = ceilf(x_s); // round up
if (x_0 == x_1) x_1 = x_0 + 1;
int y_0 = floor(y_s);
int y_1 = ceil(y_s);
int y_0 = floorf(y_s);
int y_1 = ceilf(y_s);
if (y_0 == y_1) y_1 = y_0 + 1;
float c_x_0 = x_1 - x_s;
@ -2203,11 +2203,11 @@ __global__ void stretch_sway_flip_weights_kernel(const float *src_weight_gpu, f
float x_s = x_c + (x - x_c)*cos_a + (y - y_c)*sin_a;
float y_s = y_c - (x - x_c)*sin_a + (y - y_c)*cos_a;
int x_0 = floor(x_s); // round down
int x_1 = ceil(x_s); // round up
int x_0 = floorf(x_s); // round down
int x_1 = ceilf(x_s); // round up
if (x_0 == x_1) x_1 = x_0 + 1;
int y_0 = floor(y_s);
int y_1 = ceil(y_s);
int y_0 = floorf(y_s);
int y_1 = ceilf(y_s);
if (y_0 == y_1) y_1 = y_0 + 1;
float c_x_0 = x_1 - x_s;

View File

@ -1103,10 +1103,10 @@ void assisted_excitation_forward_gpu(convolutional_layer l, network_state state)
float dh = (1 - truth.h) * beta;
//printf(" alpha = %f, beta = %f, truth.w = %f, dw = %f, tw+dw = %f, l.out_w = %d \n", alpha, beta, truth.w, dw, truth.w+dw, l.out_w);
int left = floor((truth.x - (dw + truth.w) / 2) * l.out_w);
int right = ceil((truth.x + (dw + truth.w) / 2) * l.out_w);
int top = floor((truth.y - (dh + truth.h) / 2) * l.out_h);
int bottom = ceil((truth.y + (dh + truth.h) / 2) * l.out_h);
int left = floorf((truth.x - (dw + truth.w) / 2) * l.out_w);
int right = ceilf((truth.x + (dw + truth.w) / 2) * l.out_w);
int top = floorf((truth.y - (dh + truth.h) / 2) * l.out_h);
int bottom = ceilf((truth.y + (dh + truth.h) / 2) * l.out_h);
if (left < 0) left = 0;
if (top < 0) top = 0;
if (right > l.out_w) right = l.out_w;